【发布时间】:2018-05-15 06:24:27
【问题描述】:
我有两个集合 user 和 cmets。在 user 中有字段:
const user = mongoose.Schema({
_id :("In the form of ObjectID"),
//ObjectId("5a19086e0664e832842f2c24")
user_name :{type: String},
password : {type: String}
});
和 cmets 集合:
const comments = mongoose.Schema({
user_id :{type: String},
//"5a19086e0664e832842f2c24" this is user's _id
comment : {type: String}
});
现在我想知道如何使用评论集合中字符串类型的用户 _id 填充这 2 个集合。 提前谢谢你
【问题讨论】: