You may want to check out the CouchDB project, they recently added a Mongo-like query interface. Also check out PouchDB, the JS version of Couch which can use (among other browser storage options) IndexedDB, offers a Mongo-like query interface, and syncs with Couch. There may be some good ideas in there that you can use for your own project.