I'm using mongoose to connect to MongoDB and I have a doubt about how can I make a query between two related collections
I have these Schemas.
const users = new mongoose.Schema({
name: String,
lastname: String,
age: Number,
comments: [
{
type: mongoose.Schema.Types.ObjectId,
ref: 'Comments',
}
],
}, { timestamp: true, strict: false });
const comments = new mongoose.Schema({
message: {
type: String,
},
description: {
type: String,
},
candidates: Number,
}, { timestamp: true, strict: false });
well, the idea is get all users that contains comments with candidates value > 100 Is this possible to do just one query that will return the users that have comments with that condition?
TIA !