Features
- User friendly API design, built around the awesome Monk
- Simple CRUD operations with model population
- Model validation deriving from your schema
- Custom error messages can be defined in your schema
- Normalised error responses ready for client consumption
- Automatic mongodb index setup
Install
This repository is distributed with NPM. After installing NPM, you can install Monastery via:
$ npm install --save monastery-js
Usage
const db = require('monastery-js')('localhost/mydb')
db.model('user', {
fields: {
name: { type: 'string' },
pets: [{ type: 'string' }],
address: { city: { type: 'string', minLength: 10 } },
points: [[{ type: 'number' }]]
}
})
db.user.insert({
data: {
name: 'Martin Luther',
pets: ['sparky', 'tiny'],
address: { city: 'Eisleben' },
points: [[1, 5], [3, 1]]
}
}).then(data => {
}).catch(errs => {
})
Debugging
This package uses Debug which allows you to see different levels of output:
$ DEBUG=monastery:info
$ DEBUG=monastery:*
Contributing
Coming soon...
License
Copyright 2020 Ricky Boyce. Code released under the MIT license.