Skip to content

Added support for using adapters to provide support for different persistence layers#15

Open
simonexmachina wants to merge 316 commits intopetejkim:masterfrom
simonexmachina:master
Open

Added support for using adapters to provide support for different persistence layers#15
simonexmachina wants to merge 316 commits intopetejkim:masterfrom
simonexmachina:master

Conversation

@simonexmachina
Copy link

Also includes a default Adapter that provides backwards compatibility.

Here's an example adapter for sequelize:

var Factory = require('factory-lady'),
    Adapter = Factory.Adapter;

var SequelizeAdapter = function() {};
SequelizeAdapter.prototype = new Adapter();
SequelizeAdapter.prototype.create = function(Model, props) {
  return Model.build(props);
};
SequelizeAdapter.prototype.save = function(doc, Model, cb) {
  doc.save()
    .success(function() {
      cb();
    })
    .error(function(event) {
      var err = new Error('Failed to save fixture');
      err.event = event;
      cb(err);
    });
};

var adapter = new SequelizeAdapter();
Factory.setAdapter(adapter);

simonexmachina and others added 30 commits May 4, 2015 13:35
Add ability to provide default attributes for assoc
Add multi_assoc function
Fix typo in code sample
# By Melanie VanderLugt (1) and Yannick François (1)
# Via Simon Wade (2) and Melanie VanderLugt (1)
* 'master' of github.com:aexmachina/factory-girl:
  Replace merge with lodash
  Fix typo in code sample
simonexmachina and others added 30 commits April 28, 2017 10:48
Modify chancegenerator to support methods with multiple parameters
Fix adapter usage documentation
* 'master' of github.com:aexmachina/factory-girl:
  Fix adapter usage documentation
* master:
  Allow num to be omitted in createMany when used with an array of attrs
  Fix adapter usage documentation
* extend:
  Added support for extending factories
* 'master' of github.com:aexmachina/factory-girl:
  Add missing closing quote
…alizers

Allow extending function initializers
* 'master' of github.com:aexmachina/factory-girl:
  Adding deterministic dependencies (package-lock.json) and fixing versions of sinon and sinon-chai
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.