Thursday, August 8, 2013

NoSQL UI Generator

I did an experiment combining MongoDB, JAX-RS, AngularJS and Metawidget to show how Metawidget lets you render NoSQL objects straight to the client. The advantage of this is that your client can dynamically adapt to whatever data is in your NoSQL database, without having to duplicate definitions between client and server. It's a MongoDB UI Generator!

Of course, there's nothing MongoDB-specific (or NoSQL-specific) about Metawidget. But it was great to see how easily these technologies played together. The only real gotcha was this bug, which I worked around by 'unwrapping' the $oid field:

// MongoDB's built-in ObjectId uses an $oid field, which AngularJS doesn't like to serialize

contact.put( "_id", new ObjectId().toString() );

You can download complete sample source code here. You'll need to deploy it on a Java EE compatible server (I used JBoss 7.1.1.Final) for JAX-RS, and MongoDB should be installed.

Feedback welcome!

0 comments: