1.0.5 • Published 4 years ago
mongoose-auto-api.info v1.0.5
Mongoose Auto API - Info Module
Automatic Mongoose REST API - Module to get schema info ☕
Install
npm i -S mongoose-auto-api.info
Model Setup
- Create "models" folder in root directory of project
- Add a model by adding a file for each model to the directory as follows
module.exports = {
name: 'customer',
schema: {
name: {
type: String,
unique: true,
required: true,
primaryKey: true,
},
email: {
type: String,
unique: true,
required: true,
},
products: [{
type: String
}]
},
}
- Requires name and schema Schema definitions are the same as normal mongoose definitions with a few additions primaryKey - unique field used to find documents from the API encrypted - if true field will be bcrypt encrypted, useful for passwords encoded - if true field will be base64 encoded
- Returns object modelName (String) collectionName (String) primaryKey (String) allFields (Array) listFields (Array) subDocFields (Array) encryptFields (Array) encodeFields (Array) * schema (Object)
Usage
info = require('mongoose-auto-api.info')