I've become envious of various web frameworks ability to access data with ease. It's become so easy to lookup, manipulate, and persist data objects that developers can focus more of their energy on user-interaction.
In the hopes that it will become like this for desktop applications, I started putting together a simple data-mapper for GObject. It is incredibly basic in its current state, but I intend to add features out of my own needs.
Only a simplistic Sqlite backend is currently implemented; but the idea is to support numerous data sources such as json, yaml, and libgda.
It's written in Vala and consumption looks something like the following.
2 debug ("%s", ((Person)obj).name);
3 });
After a little more effort, the following should also be supported.
2 Condition.str_equal ("name", "Christian").and (
3 Condition.int_gt ("age", 18))
4 ).first ().last_name;
That will be simplified more when Vala bug #528436 is fixed. Fixing this bug will allow for automatic boxing/unboxing of variables into GValue's. That means you will not need to use Condition.str_equal, but Condition.equal instead.
Source: git://git.dronelabs.com/git/users/chergert/godm.git
Licensed: LGPL-3

Comments (3)
Great idea but what will happen if we change the name of the property ‘name’ to ‘fullname’ ? The approach with enclosed strings to point the property is very fragile. It’s not compile time checked and there is not refactoring support.
Yeah, I totally agree. I just have not come up with how I want to do that.
What do you think of passing an enum?
Condition.equal (PersonColumn.Name, “blah”)?
Actually, what I’d like to do is add a Column type which can be used. Then you can have static fields on your class for this.
public static Column<string> Name = new Column<string> (“name”);
Then, in our queries, you can use.
Condition.equal (Person.Name, “Christian”)