Hi , I am new to MongoDB, I am using Mongoose to create this schema model:
I am looking for to write a query that gives me the stores of a customer with customer ID “12345” that has stores points greater than 5.
const customerSchema = new mongoose.Schema({
name: {
type: String,
required: [true, 'Error: Name is required!']
},
stores: [
{
store: {
type: mongoose.Schema.Types.ObjectId,
ref: 'Store'
},
points: {
type: Number
}
}
]
})
Hi Anuj,
Thanks for your suggestion, I tried it but it seems it gives me all the stores, not only the one that has more than 5 points. Here is the code I have: