afloyd / mongo-migrate

MIT License
159 stars 81 forks source link

Outdated Examples #39

Closed siboulet closed 8 years ago

siboulet commented 9 years ago

It seems the examples are outdated, or perhaps its because I'm using the latest 1.2.0 with Mongo 2.x, but I have found the following to work:

exports.up = function(db, next){
    var owners = db.collection('owners');
    owners.insert({name: 'taylor'}, next);
};

exports.down = function(db, next){
    var owners = db.collection('owners');
    pets.findAndModify({name: 'taylor'}, [], {}, { remove: true }, next);
};

It's no longer necessary to require mongodb in migrations.

catamphetamine commented 8 years ago

+1

The examples in the README are broken. @siboulet way works.

raiyankamal commented 8 years ago

Hi, I just sent a PR to fix this issue https://github.com/afloyd/mongo-migrate/pull/53. Hopefully the original author will merge it soon. In the mean time, please upvote my PR to bring it to his attention.

afloyd commented 8 years ago

Merged PR #53