mongoose-detail
v0.0.6
Published
Mongoose plugin to expose schema definitions programmatically
Downloads
43
Readme
mongoose-detail
Mongoose plugin to expose schema definitions programmatically
Install
$ npm install --save mongoose-detail
$ yarn add mongoose-detail
Use
const mongooseDetail = require('mongoose-detail')
const mongoose = require('mongoose')
const kittySchema = mongoose.Schema({
name: { type: String, required: true, unique: true },
age: { type: Number },
})
kittySchema.plugin(mongooseDetail, {
skip: ['_id', '__v'], // Optional Properties to skip. The default value is []
name: 'detail', // Optional static function name. The default value is 'detail'
})
const Kitten = mongoose.model('Kitten', kittySchema)
Kitten.detail()
// {
// name: { type: String, required: true, unique: true },
// age: { type: Number },
// }