(重新)从json填充mongodb集合 - mongoose

时间:2012-11-02 03:08:19

标签: node.js mongodb mongoose

enter code here您有没有办法使用mongoose从json数组重新填充mongo集合?

我有这个架构。

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}

});

并希望用这个json填充它并将其保存到集合中。

   {"_id":"506b8922a6bd97d322000011",
"user_id":"504aaeef898f541527000012",
"note":"a note","created":"2012-03-10T00:38:58.000Z",
"last_mod":"2012-03-10T00:38:58.000Z"}

我的目标是在运行一些测试后将数据库重置为某个状态,这些测试会添加删除并更改其中的一些数据。 但是,如果有更方便的方法从mongoose / mongo中的先前状态实现数据库重置,我非常感谢任何指针。保持版本控制信息也很不错。

感谢

0 个答案:

没有答案
相关问题