Saturday, May 18, 2013

Quick look

MungoDS is an Document API to the Google App Engine Datastore. It introduces the concept of DB, DBCollection, and DBObject. It is designed to make the storing of JSON documents in the most native way possible.

Which simply means that JSON documents are translated directly into Entities (DBObject) under a Kind (DBCollection) and within a Namespace (DB).

It's still a work and progress and it continues to evolve into (hopefully) a mature API that can be used in a production environment.

Here's a quick example:

Mungo mungo = new Mungo(); 
  DB testDB = mungo.getDB("testDB");
  DBCollection messages = testDB.createCollection("Message");
  BasicDBObject obj = new BasicDBObject("{'hello' : 'world'}")
  obj.put("hi", "there");
  WriteResult wr = messages.insert(obj); // Done!
  DBObject result = messages.findOne(obj.getId()); // Get it

You can also do:

Message msg = messages.findOne(obj.getId()).as(Message.class); 
So you can think of this as "auto-wiring" JSON documents into the GAE Datastore.

Try it:
GitHub Repository

Join us:
Google+ Community Page