I need help with a query to find all groups that have the subject of chemistry and match a specific user's schedule. The current query isn't returning any results, and I suspect there might be a syntax error in the code. I'm unsure of where I might be going wrong.
const mongoose = require('mongoose');
const Schema = mongoose.Schema;
const GroupSchema = new Schema({
owner: {type: mongoose.Schema.ObjectId, ref: 'users'},
subject: String,
date: {type: Date, default: Date.now},
mondayStart: Number,
mondayEnd: Number,
tuesdayStart: Number,
tuesdayEnd: Number,
wednesdayStart: Number,
wednesdayEnd: Number
});
module.exports = Group = mongoose.model('groups', GroupSchema);
let query = Group.find({
subject: '/chemistry/',
$or: [
{$and: [ {mondayStart: {gte: 6}}, {mondayEnd: {lte: 8}}] },
{$and: [ {tuesdayStart: {gte: 9}}, {tuesdayEnd: {lte:13}}] },
{$and: [ {wednesdayStart: {gte: 9}}, {wednesdayEnd: {lte: 12}}
]
})