Skip to content

mohamedgomran/loopback-mixin-mongo-seq

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

27 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

MONGO-SEQ Build Status

loopback v3 mixin to add support for sequential property.

usage

  • install via npm.
npm install loopback-mixin-mongo-seq
  • update server.js to load mixin.
const loopbackMixinMongoSeq = require('loopback-mixin-mongo-seq');

loopbackMixinMongoSeq(app, {
  dataSource: 'MongoDS', modelName: 'Counter'
});
  • add mixins property to the required model.
"mixins": {
  "Seq" : {
    "propertyName": "ID",
    "step": 1,
    "initialVal": 1,
    "readOnly": true,
    "definition": {
      "index": { "unique": true }
    }
  }
}

options

propertyName: property name, defaults to ID.

step: defaults to 1.

initialVal: value to start counter from if the sequence doesn't exist, defaults to the highest record in the target model if not found then 1.

readOnly: if the value should be protested against changes, defaults to true.

definition: property definition ( can be used to add index to property), defaults to {}.

DEBUG MODE

DEBUG='loopback:mixin:mongo-seq'

About

loopback mixin to add support for sequential property

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • JavaScript 100.0%