i have two schemas
var UserSchema =new mongoose.Schema({
username:String,
password:String,
user_email:String,
user_contacts:[
{
type:mongoose.Schema.Types.ObjectId,
ref:"User"
}
]
})
module.exports=mongoose.model("User",UserSchema);
and
var friendRequestSchema=new mongoose.Schema({
requester:{
type:mongoose.Schema.Types.ObjectId,
ref:"User"
},
recipient:{
type:mongoose.Schema.Types.ObjectId,
ref:"User"
},
//1 for requested , 2 for accepted , 3 for rejected
status:Number
});
module.exports=mongoose.model("FriendRequest",friendRequestSchema);
and i want to find all friend requests with specific user id for requester field ,then i want to get all recipient users of these requests, and finally adding them to a dictionary where the key is the recipient user and the value is the friendRequest associated with it so i can pass it to a ejs file like this:
res.render("myrequests",{myDictionary:myDictionary});