Hi all in my user model i am storing the following data
request_rec:[
{
type: mongoose.Schema.Types.ObjectId,
ref: 'Trip',
}
],
request_send:[
{
type: mongoose.Schema.Types.ObjectId,
ref: 'Trip',
}
],
I am keeping the requests_rec, request_send arrays limited to 3 recent items by using $push $slice. So that i can show 3 items under request_send, request_received if he needs to view more then i am planning to fetch from trip model.
I feels i can easily handle addition of new request_send, request_received. But i am feeling confused regarding how i shall keep this list updated when i remove items from request_send,request_received after accepting a request. Please guide me regarding how i shall keep the request_send,request_received array filled after removing an item(ie. if i removed an item from request_received in user model then if there are more requests pending how shall copy it to request_received in usermodel).