A simple ODM for mongodb
Wongo is a mongoose.js wrapper that unwraps certain ORM functionality in an attempt to reduce code, increase predictibility and tweak functionality.
A wrapper that unwraps a wrapper. Crazy right?
Disclaimer: This project is extremely immature, but feel free to take a peek around and be critical.
# find examplequery = where: name: 'mint'wongofind 'Mock'query# docs is a raw json array of objects - i.e. it uses lean()# save exampledocument = name: 'mint'wongosave 'Mock'document# doc is a raw json object# schema definition examplewongo.schema = 'Mock'fields:name: Stringplugins:'my existing mongoose plugin': plugin_refoption1: 'meow'hooks::# do something to the document before it is saved (will be a json doc, not a mongoose ORM doc)next:# do something to the document after it is saved (note, this allows async unlike mongoose)next
Want more examples? Check out the tests folder or just fill out an issue and ask.
This library was created because I was annoyed by the little things in mongoosejs.
Disclaimer: Before I get into the annoyances, mongoosejs is a terrific library. Nothing really comes close to it in terms of feature set, so the point of this project is not to reinvite the whell, but to make it fit on my car. If you're driving a truck, you shouldn't use this library.
I use mocha. So, you should be able to run the 'mocha' command in the project folder and be done. However, you will need to add a db_config.json file that has the db_config.url parameter in it. This file is not committed to git for obvious reasons.
Here is a format you can use: