Home

Awesome

GStorm - Groovy Single Table ORM

GStorm is a light-weight persistence helper that lets you persist data without any boilerplate code. Also it can act as and ORM for CSV files.

Example

class Person { String name, project }       // this is your model class

def g = new Gstorm()
g.stormify(Person)                          // table automatically gets created for this class

def person = new Person(name: "kunal", project: "gstorm")

person.save()                               // which saves object to db

def result = Person.where("name = 'kunal'") // pass any standard SQL where clause
println result

println "all records -> ${Person.all}"      // get all objects from db

person.name = "kunal dabir"
person.save()                               // saves the object back to db

println Person.get(person.id)               // loads the object by id

person.delete()                             // delete the person from db

Running it

To see gstorm in action just execute following from command line:

groovy https://raw.github.com/kdabir/gstorm/master/examples/getting_started.groovy

Provided you have groovy installed, you don't need to install anything else.


Why Gstorm?

In groovy scripts, when you need persistence, and you often feel hibernate is overkill but handwritten SQL is headache. You don't want to connect to external Database server and still wish you could just create a table and save objects as quickly as possible. You hate writing SQL for trivial CRUD but still want to be able to harness the power of SQL when need be. You can then try Gstorm.

Gstorm take very simple approach to solve this problem by focusing just on needs of persistence mechanism required for small scripts/projects.

The market is already flooded with ORMs and NoSQL databases. It's pointless to introduce anything that's heavy, complex, rigid and tries to solve all the problems in the world.

What good a Single Table ORM would do?

Gstorm uses HSQLDB syntax internally.


Getting started

GStorm is available in jcenter repository Grab GStorm using

@GrabConfig(systemClassLoader = true)
@Grab('io.github.kdabir.gstorm:gstorm:0.7.1')

Create instance of Gstorm

def g = new Gstorm()

You may pass optionally pass object of java.sql.Connection or groovy.sql.Sql

def g = new Gstorm(sql)

where sql is an instance of groovy.sql.Sql

And gstormify your model

g.stormify(Person)

Just go through the example's source and test and have fun.


Project status

Gstorm is tiny project with very specific use case. There is long list of items that I would want to complete before calling it feature complete. The project is under active development and is not yet suitable for production grade applications.

Changelog :

v0.7.1

v0.7

v0.6

v0.5

v0.4

v0.3

v0.2

v0.1