我有两个集合 users 和 user_details
用户收集样本数据
{
"_id" : ObjectId("60d2e60d7164d8d761fc5e63"),
"username" : "test",
"email": "a@example.com"
}
user_details samples is
{
"_id" : ObjectId("60cc3f83baa1941c85d8eee9"),
"user_id": "60d2e60d7164d8d761fc5e63"
"Address" : "Test add",
"city": "test city"
}
In mongoose schema of user details
new mongoose.Schema({
user_id: {
type: String,
ref: 'User',
},
Address : String,
City : String,
}, { collection: 'user_details' });
While fetching it inside populate I have added it
populate: [
{ path: 'User'}
],
但用户详细信息未显示在结果中