Skip to content
This repository has been archived by the owner on Oct 19, 2018. It is now read-only.
/ fixer Public archive

Setup your test database using fixtures in a breeze.

Notifications You must be signed in to change notification settings

olalonde/fixer

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Fixer

Node.js module to setup your test database using fixtures in a breeze. Inspired by Rails fixtures.

Limitations

  • Only supports sequelize ORM at the moment.
  • I haven't tested many-to-many relationships for now but I will as soon as possible.

Install

npm install fixer

Usage

See example/load_fixtures.js.

var fixer = require('fixer');
/**
 * @param {Object} fixtures associative object. keys represent model names and values contain an array of fixtures for that model. fixture are simple associative objects.
 * @param {Object} models associative object. key represents the model
 * name and value is the Sequelize model
 */
fixer(fixtures, models).load(function (err) {
  if (err) return console.error(err);
  console.log('Finished loading fixtures into database.');
});

Example fixtures (in coffeescript):

students.coffee

module.exports =
  oli:
    first_name: 'Olivier'
    last_name: 'Lalonde'
    email: 'olalonde@gmail.com'
    school: 'NYU'
  mark:
    first_name: 'Mark'
    last_name: 'Zuckerberg'
    email: 'mark@facebook.com'
    school: 'Harvard'

schools.coffee

module.exports =
  'NYU':
    name: 'New York University'
    email: 'info@nyu.com'
  'Harvard':
    name: 'University of Harvard'
    email: 'info@harvard.edu'

You can reference other fixtures by their key. For example, students.oli.school reference fixture schools.NYU.

About

Setup your test database using fixtures in a breeze.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published