Skip to content

deepwell/meteor-fixture-loader

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Fixture Loader

Makes it easy to load fixtures in a set order synchronously.

How to use: Create functions that add fixtures to your database eg:

function insertCountries() {
  var countries = [{
    name: 'Australia',
    code: 'AU'
  }];

  for (var i = 0, length = countries.length; i < length; i++) {
    Countries.insert(countries[i]);
  }
}
registerFixture('countries', insertCountries);

function insertPorts() {
  var ports = [{
    name: 'Adelaide',
    countryId: Countries.findOne({ code: 'AU' }, { limit: 1 })._id
  }];

  for (var i = 0, length = ports.length; i < length; i++) {
    Ports.insert(ports[i]);
  }
}

// register this function and depend upon 'countries' fixture being loaded first
registerFixture('ports', insertPorts, 'countries');

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Packages

No packages published