Nightingale Posing Mischievously

npm

Need private packages and team management tools?Check out npm Orgs. »

mongoose-auto-api.info

1.0.2 • 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)
    • encryptFields (Array)
    • encodeFields (Array)
    • schema (Object)

Usage

info = require('mongoose-auto-api.info')

install

npm i mongoose-auto-api.info

Downloadsweekly downloads

33

version

1.0.2

license

MIT

homepage

github.com

repository

Gitgithub

last publish

collaborators

  • avatar
Report a vulnerability