Questions tagged «populate»

10
保存后填充猫鼬
我无法手动或自动在新保存的对象上填充创建者字段...我唯一能找到的方法是重新查询我已经想要做的对象。 这是设置: var userSchema = new mongoose.Schema({ name: String, }); var User = db.model('User', userSchema); var bookSchema = new mongoose.Schema({ _creator: { type: mongoose.Schema.Types.ObjectId, ref: 'User' }, description: String, }); var Book = db.model('Book', bookSchema); 这是我拉头发的地方 var user = new User(); user.save(function(err) { var book = new Book({ _creator: user, …

10
猫鼬:人口众多(人口众多)
我有Category模特: Category: ... articles: [{type:ObjectId, ref:'Article'}] 文章模型包含对的引用Account model。 Article: ... account: {type:ObjectId, ref:'Account'} 因此,使用填充的articles类别模型将是: { //category articles: //this field is populated [ { account: 52386c14fbb3e9ef28000001, // I want this field to be populated date: Fri Sep 20 2013 00:00:00 GMT+0400 (MSK), title: 'Article 1' } ], title: 'Category 1' } …
By using our site, you acknowledge that you have read and understand our Cookie Policy and Privacy Policy.
Licensed under cc by-sa 3.0 with attribution required.