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
moduleexports =name: 'customer'schema:name:type: Stringunique: truerequired: trueprimaryKey: trueemail:type: Stringunique: truerequired: trueproducts: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
- Schema definitions are the same as normal mongoose definitions with a few additions
- Returns object
- modelName (String)
- collectionName (String)
- primaryKey (String)
- allFields (Array)
- listFields (Array)
- subDocFields (Array)
- encryptFields (Array)
- encodeFields (Array)
- schema (Object)
Usage
info =