mongoose-auto-api.info

1.0.5 • Public • Published

Mongoose Auto API - Info Module

Build Status npm version

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')

Package Sidebar

Install

npm i mongoose-auto-api.info

Weekly Downloads

2

Version

1.0.5

License

MIT

Unpacked Size

6.9 kB

Total Files

7

Last publish

Collaborators

  • edmundpf