A mongoose manager wrapper that provides some common utilities and extends it to support promises.
About the Spur Framework
The Spur Framework is a collection of commonly used Node.JS libraries used to create common application types with shared libraries.
Visit NPMJS.org for a full list of Spur Framework libraries >>
Quick start
Installing
$ npm install spur-mongoosemanager --save
Usage
src/injector.js
spur = require "spur-ioc"spurCommon = require"spur-common"spurMongoosemanager = require "spur-mongoosemanager" = ioc = spurcreate"demo" # register folders in your project to be autoinjected iocregisterFolders __dirname "demo" iocmergespurCommon iocmergespurMongoosemanager ioc
demo/DinerModel.coffee
Definition of a MongoDB schemea for a diner.
= extends MongooseModel :-> super @_model = @createModel : # Define a schema schema = _id: type: Number required: true unique: true index: true firstName: type: String trim: true lastName: type: String trim: true schemavirtual"globalId"get this_id schemaset 'toJSON' virtuals: true MongooseManagermodel 'Diner'schema : GlobalId: globalId firstName: firstName lastName: lastName
demo/DinerService.coffee
Service that uses the mongodb diner model created above.
= : Diner findOneAsync _id: id then diner error Loggererrorerror
start.coffee
injector = require "./src/injector" injectorinject UncaughtHanderlisten # Initiate the connection MongooseMangerconnect
Contributing
We accept pull requests
Please send in pull requests and they will be reviewed in a timely manner. Please review this generic guide to submitting a good pull requests. The only things we ask in addition are the following:
- Please submit small pull requests
- Provide a good description of the changes
- Code changes must include tests
- Be nice to each other in comments. 😇
Style guide
The majority of the settings are controlled using an EditorConfig configuration file. To use it please download a plugin for your editor of choice.
All tests should pass
To run the test suite, first install the dependancies, then run npm test
$ npm install$ npm test