sails-industrial-factory
Simple model factory for Sails.js with Sequelize inspired by Sails Factory
Installation
npm install sails-industrial-factory
Usage
Defining factories
Define a factory by giving it a name and an optional model name. The factory name will be the default model name (parent model or the name itself) if model name is not provided.
var factory = ; factory ; factoryparent"user" ; factoryparent"user";
Using factories
//Callbackfactory; factory; factory; //Promisefactory ; factory ; factory ;
Auto increment attributes
Attributes can have an auto_increment option. By default, sequence will increment by 1, otherwise it will increment by whatever value the auto_increment option is set to. Counting starts at the initial value given. Sequence is shared among parent and children.
factory ; factoryparent"user"; factory; factory; factory;
Loading factories
Calling .load() without parameter will try to load factory definitions from test/factories folder.
// api/models/User.jsmoduleexports = attributes: first_name: type: SequelizeSTRING allowNull: false last_name: type: SequelizeSTRING allowNull: false last_name: type: SequelizeSTRING allowNull: false active: type: SequelizeBOOLEAN allowNull: false defaultValue: false ; // test/factories/User.jsmodule { factory factoryparent"user" ;}; // test/bootstrap.js;
To load factory files from different folder:
factory;