0
我有一个猫鼬模式模型,看起来像下面的示例。帐户字段是一组帐户ID。添加到Mongoose模式中的数组
var ListingSchema = new Schema({
listing: { type: String, required: true },
admin: { type: String, required: true, index: true },
accounts: [{ type: String, index: true }]
});
现在在我的节点/快递后台,我添加一个条目,像这样:
Listing.create({
listing: req.body.id,
admin: req.session.userID,
account: req.session.userID
}, function (err){
if (err) throw err;
else res.send({success:true});
});
但是我不添加到账户场正确,因为它是一个数组。我怎样才能做到这一点?
该创建似乎不适用于我的阵列... – Coop