这是我的数据库的一部分:
new mongoose.Schema({
author: {
type: mongoose.Schema.Types.ObjectId,
ref: 'Barber',
required: true,
},
month: {
type: Number,
required: true,
},
availability: [{
day: {
type: Number,
required: true,
},
hours: [{
hour: {
type: Number,
required: true,
},
status: String,
clientName: String,
serviceType: String,
}],
}],
});
我正在尝试创建一个查询,该查询将使我能够确定数据库中是否在给定的一天中已经存在给定的小时数(假设:在第8天,是否已经计算了800小时)。 / p>
我尝试了以下表达式:
Availability.find(
{ $and: [{ 'availability.hours.hour': '800' }, { 'availability.day': 8 }] },
);
...但是它给我的是true而不是false,因为第8天和第800小时都存在,但我要查找的是第8天是否存在800小时。
你们有什么提示吗?