mongoose-rest-helper
Provides some convenience functions that can bridge mongoose and your REST endpoints. Nothing special really.
How to get started:
npm install mongoose-rest-helper
Usage
The following illustrates a typical use case where we map CRUD functions to the mongoose-rest-helper. This is verbose, you could easily create this for all your models.
mongooseRestHelper = require 'mongoose-rest-helper' module.exports = UPDATE_EXCLUDEFIELDS = '_id' :
Return all objects (with pagination, and scoping through accountId)
: return cb "accountId parameter is required." unless accountId settings = baseQuery: accountId : mongooseRestHelperasObjectId accountId defaultSort: 'name' defaultSelect: null defaultCount: 1000 mongooseRestHelperall @modelsettingsoptionscb
Get an entity for it's id
: return cb "id parameter is required." unless id mongooseRestHelpergetById @modelidnulloptionscb
Destroy an entity
: return cb "id parameter is required." unless id settings = mongooseRestHelperdestroy @modelidsettingscb
Create an entity
: return cb "accountId parameter is required." unless accountId settings = objs.accountId = mongooseRestHelperasObjectId accountId mongooseRestHelpercreate @modelsettingsobjsoptionscb
Update an entity
: settings = exclude : UPDATE_EXCLUDEFIELDS mongooseRestHelperpatch @modelidsettingsobjoptionscb
Stuff
- npm install
- grunt watch
- grunt deploy
See also
- hapi-auth-bearer-mw
- hapi-loggly
- hapi-mandrill
- hapi-mongoose-db-connector
- hapi-oauth-store-multi-tenant
- hapi-routes-authorization-and-session-management
- hapi-routes-oauth-management
- hapi-routes-roles
- hapi-routes-status
- hapi-routes-users-authorizations
- hapi-routes-users
- hapi-user-store-multi-tenant
and additionally
- api-pagination
- mongoose-oauth-store-multi-tenant
- mongoose-rest-helper
- mongoose-user-store-multi-tenant
Contributing to mongoose-rest-helper
- Check out the latest master to make sure the feature hasn't been implemented or the bug hasn't been fixed yet
- Check out the issue tracker to make sure someone already hasn't requested it and/or contributed it
- Fork the project
- Start a feature/bugfix branch
- Commit and push until you are happy with your contribution
- Make sure to add tests for it. This is important so I don't break it in a future version unintentionally.
- Please try not to mess with the package.json, version, or history. If you want to have your own version, or is otherwise necessary, that is fine, but please isolate to its own commit so I can cherry-pick around it.
Copyright
Copyright (c) 2013-2014 Martin Wawrusch See LICENSE for further details.