Closed artforlife closed 7 years ago
I haven't used Mongo or this library in a few years... But it looks like you need to first get your collection.
Try:
'use strict';
module.exports = {
up: function (db, next) {
// TODO write your migration here
var Activity = db.Collection('Activity');
Activity.update({}, {$set: {"runtime" : {
"started" : false,
"startDate" : null,
"endDate" : null
}
}
},
false, true);
next();
},
down: function (db, next) {
// TODO write the statements to rollback your migration (if possible)
var Activity = db.Collection('Activity');
Activity.update({}, {$unset: {"runtime" : ""}}, false, true);
next();
}
};`
It still does not work.
TypeError: db.Collection is not a function
If I console.log
the db
it outputs an object with some fields. However, this object has neither get
nor Collection
method.
I am trying to do a very basic migration by adding a field to all documents. However, I keep getting an error "TypeError: Cannot read property 'update' of undefined". Here is my migration file:
If I run the same queries in MongoDB shell (Robomongo) they work just fine.