sails-fixtures

2.0.0 • Public • Published

Fixtures for sails

JSON fixtures. Data are automatically loaded and checked every time you lift your sails (if you use bootstrap from examples). Suggestions and pull requests are welcome.

Howto

  1. Setup your models
  2. Edit your bootstrap.js
  3. Fill data
  4. sails lift

Bootstrap config

Simply call #init(config, callback), it will handle the rest.

var fixtures = require('sails-fixtures');
 
module.exports.bootstrap = function(next)
{
  fixtures.init({
    'dir':'/path/to/your/fixtures/directory',
    'pattern':'*.json' // Default is '*.json'
  }, next);
};

Data format

Fixtures are loaded in parallel. Their contents are loaded in series in specified order.

[
  {
    "model":"modelname",
    "items":[
      {
        "id":1,
        "attribute":"foo"
      },
      {
        "id":50,
        "attribute":"bar"
      }
    ]
  },
  {
    "model":"anothermodel",
    "items":[
      {
        "id":7,
        "name":"test"
      }
    ]
  }
]

Versions

Current Tags

  • Version
    Downloads (Last 7 Days)
    • Tag
  • 2.0.0
    4
    • latest

Version History

Package Sidebar

Install

npm i sails-fixtures

Weekly Downloads

9

Version

2.0.0

License

MIT

Unpacked Size

8.51 kB

Total Files

4

Last publish

Collaborators

  • just-paja