Reputation: 165
This is my Mongoose model of conversation object:
const conversationSchema = mongoose.Schema({
participants: [
{
id_profile: { type: mongoose.Schema.Types.ObjectId, ref: 'User', required: true }
}
]
});
How I can find a conversation object that contains two objects in the array "participants" that have ID = 123456 and ID = 654321? The order of objects in array "participants" can be different.
conversation = {
participants: [
{ id_profile: '123456' },
{ id_profile: '654321' }
]
}
conversation = {
participants: [
{ id_profile: '654321' },
{ id_profile: '123456' }
]
}
How to create a query using Mongoose?
Upvotes: 1
Views: 59