I'm very new in mongoose and node js. I get some troubles in my project. here is my user model
UserSchema = new Schema({
account:String,
password:String,
display_name:String )}
and friends model
FriendSchema = new Schema({
friend_from_id:{
type:Schema.ObjectId,
ref:'users'
},
friend_to_id:{
type:Schema.ObjectId,
ref:'users'
}});
and user_status model
UserStatusSchema = new Schema({
user_id:{
type:Schema.ObjectId,
ref:'users'
},
status:{
type:Boolean
},
status_text:String,
last_updated_at:String});
how can I populate or any way to make a result from friend model like this
{
"_id": "55145b6b8b9c9e6c1f739441",
"friend_to_id": {
"_id": "5502976dbef9fa180d28ea21",
"display_name": "Jason",
"account": "xxx@ginmed.com",
"status":false,
"status::"how it's going"
},
"friend_from_id": {
"_id": "5502976dbef9fa180d28ea21",
"display_name": "SonPham",
"account": "yyy@ginmed.com",
"status":true,
"status::"how to do it"}
this mean I want to combine both user_status and user model in a field of friend model