Skip to content
Factory builder for Mongoose & Seed
JavaScript Makefile
Find file
Failed to load latest commit information.
lib Inherit hooks from ancestors
test Inherit hooks from ancestors
.gitignore Initial commit
.travis.yml Run on 0.11 Release 1.0.0
LICENSE Add a license
Makefile Bump Version to 1.1.0, Add contributors, update
package.json Bump Version to 1.1.0, Add contributors, update

Build Status

Seed Forge

Seed Forge is a powerful factory builder for Seed and Mongoose


Public methods

var define     = require('seed-forge').define;
var list       = require('seed-forge').list;
var build      = require('seed-forge').build;
var factory    = require('seed-forge').factory;
var attributes = require('seed-forge').attributes;

Define a factory

  .set('name', 'Name')
  .set('url', function () {
    return '';
  .set('eyes.left', 'blue')
  .set('eyes.right', 'green')
  .set('email', function (n) {
    return 'example' + n + ''
  .set('age', 33)
  .set('admin', false);


define('Admin', User)
  .set('age', 44)
  .set('admin', true)
  .set('disabled', false);

define('DisabledAdmin', User)
  .set('disabled', true);

Create a record from factory

factory('User', fn);
factory('User', { override: 'attributes' }, fn);

Create multiple records

list('User', 10, fn); // Will create 10 users.

Build a record, without saving it

var user = build('User');
var user = build('User', { override: 'attributes' });

Use hooks for creating relationships

define('Account', Account)
  .hook('pre:save', function(obj, next) {
    if (!obj.get('owner')) { // if (!obj.owner) {
      factory('User', function(err, user) {
        if (err) return next(err);
        obj.set('owner', user);
    } else {

Get model attributes from a factory

var attrs = attributes('User');


$ npm install seed-forge


MIT License

Something went wrong with that request. Please try again.