【发布时间】:2015-04-08 19:09:04
【问题描述】:
我有一个类似于以下示例的猫鼬模式模型。帐户字段是一个帐户 ID 数组。
var ListingSchema = new Schema({
listing: { type: String, required: true },
admin: { type: String, required: true, index: true },
accounts: [{ type: String, index: true }]
});
现在在我的 Node/Express 后端中,我添加了一个类似这样的条目:
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});
});
但是我没有正确添加到帐户字段,因为它是一个数组。我该怎么做?
【问题讨论】: