enter code here
Hi is there a way to repopulate a mongo collection from a json array using mongoose?
I have this schema.
var UserNote_Schema = new Schema({
user_id: {type:ObjectId, ref:require('../User/User_Schema.js')},
note: {type:String},
created: {type:Date},
last_mod: {type:Date}
});
and would like to populate it with this json and have it save to the collection.
{"_id":"506b8922a6bd97d322000011",
"user_id":"504aaeef898f541527000012",
"note":"a note","created":"2012-03-10T00:38:58.000Z",
"last_mod":"2012-03-10T00:38:58.000Z"}
My goal is to reset my database to a certain state after running some tests which add remove and change some of the data within. However, if there is more convenient way of achieving a database reset from a previous state in mongoose/mongo I'd much appreciate any pointers. Keeping the versioning info would also be nice.
thanks