afloyd / mongo-migrate

MIT License
159 stars 81 forks source link

TypeError: db.Collection is not a function #72

Open raztud opened 6 years ago

raztud commented 6 years ago

From your example

exports.up = function (db, next) {
    var pets = db.Collection('pets');
    pets.insert({name: 'tobi'}, next);
};

I get TypeError: db.Collection is not a function when I run ./node_modules/mongodb-migrate -runmm -dbc {"host":"localhost","db":"mydb","port":27017} up

Full trace:

at Migration.exports.up (migrations/0100-migrate.js:5:17)
    at next (node_modules/mongodb-migrate/lib/set.js:161:24)
    at Set._migrate (node_modules/mongodb-migrate/lib/set.js:212:2)
    at node_modules/mongodb-migrate/lib/set.js:102:8
    at Set.load (node_modules/mongodb-migrate/lib/set.js:59:2)
    at Set.migrate (node_modules/mongodb-migrate/lib/set.js:93:7)
    at Set.up (node_modules/mongodb-migrate/lib/set.js:79:7)
    at node_modules/mongodb-migrate/index.js:312:19
    at handleCallback (node_modules/mongodb/lib/utils.js:120:56)
    at node_modules/mongodb/lib/cursor.js:861:16
    at handleCallback (node_modules/mongodb-core/lib/cursor.js:171:5)
    at setCursorDeadAndNotified (node_modules/mongodb-core/lib/cursor.js:505:3)
    at nextFunction (node_modules/mongodb-core/lib/cursor.js:608:12)
    at Cursor.next [as _next] (node_modules/mongodb-core/lib/cursor.js:701:3)
    at fetchDocs (node_modules/mongodb/lib/cursor.js:857:10)
    at node_modules/mongodb/lib/cursor.js:880:7

Version:

npm view mongodb-migrate version
2.0.2
pierigp commented 6 years ago

@raztud This one works for me mongodb-migrate 2.0.2 mongodb 3.0.10

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