https://github.com/cludden/mycro-mongoose-rest
https://github.com/cludden/mycro-mongoose-rest
Last synced: 2 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/cludden/mycro-mongoose-rest
- Owner: cludden
- Created: 2015-12-08T14:58:22.000Z (over 9 years ago)
- Default Branch: master
- Last Pushed: 2016-01-22T16:23:02.000Z (over 9 years ago)
- Last Synced: 2025-03-15T23:36:11.449Z (3 months ago)
- Language: JavaScript
- Size: 14.6 KB
- Stars: 0
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# mycro-mongoose-rest
a [restify-mongoose](https://github.com/saintedlama/restify-mongoose) hook for [mycro](https://github.com/cludden/mycro)**NOTE** *This is still very much a work in progress and is not yet suitable for use in production*
## Install
```javascript
npm install --save mycro-mongoose-rest
```## General Usage
1. Define a config file at `/config/restify-mongoose.js`
2. Define a `defaults` attribute that defines the default options for `restify-mongoose`
3. Define a `models` attribute with a key for every model that you intend to create a `restify-mongoose` resource for.```javascript
// in /config/restify-mongoose.jsmodule.exports = {
// define default options for all models
defaults: {
pageSize: 20,
baseUrl: 'https://www.example.com/api'
}models: {
// use defaults for `group` model
group: true,// define additional options for `user` model
user: {
// define options that will be applied to all Resource methods
defaults: {
detailProjection: function(req, item, cb) {
cb(null, item.toObject());
},
filter: function(req, res) {
return { status: 'active' };
},
listProjection: function(req, item, cb) {
cb(null, item.toObject());
}
},
// define options that will be applied to the `query` method
query: {
sort: '-first'
}
}
}
}
```## Contributing
1. [Fork it](https://github.com/cludden/mycro-mongoose-rest/fork)
2. Create your feature branch (`git checkout -b my-new-feature`)
3. Commit your changes (`git commit -am 'Add some feature'`)
4. Push to the branch (`git push origin my-new-feature`)
5. Create new Pull Request## License
Copyright (c) 2015 Chris Ludden.
Licensed under the [MIT license](LICENSE.md).