我只需找到该数据,可用性日期大于我当前的日期。我在哪里放 $ gte
function getBookingList(){
return new Promise(function(resolve,reject){
Booking.find(
{userId: req.userId}
).populate({
path:'expId',
model:Experiences
}).populate({
path:'slotId',
model:Availability
}).exec(function(err,result){
if(err){
reject(err);
}if(result){
resolve(result);
}else{
resolve({"msg":"Booking Experiences not found."});
}
});
});
}
我找到了今天要比较的日期。
var today = new Date(new Date().setHours(0,0,0,0));;
var todaynew = today.toISOString();
我知道使用
date: {$gte: todaynew}
以上我可以得到它,但我在哪里放入我的查询?
答案 0 :(得分:0)
您的查询应该是这样的:
function getBookingList(){
return new Promise(function(resolve,reject){
var today = new Date(new Date().setHours(0,0,0,0));;
var todaynew = today.toISOString();
Booking.find(
{userId: req.userId}
).populate({
path:'expId',
model:Experiences
}).populate({
path:'slotId',
match: { date: { $gte: new date() || todaynew }}
model:Availability
}).exec(function(err,result){
if(err){
reject(err);
}if(result){
resolve(result);
}else{
resolve({"msg":"Booking Experiences not found."});
}
});
});
}