为什么mongo客户返回查询的答案,而猫鼬没有。
db.dates.find({"date_out" : { $gte : ISODate("2018-11-12T00:00:00.000Z") }}).pretty()
{
"_id" : ObjectId("5be8a9eeda7bbc1fc40c1fa1"),
"user" : "some.user@example.com",
"date_in" : ISODate("2018-11-11T22:15:10.095Z"),
"date_out" : ISODate("2018-11-14T22:00:00Z"),
"userId" : "5be5a96e6db7be0568ea6e47"
}
但是当我尝试在Mongoose中执行相同的查询时,它不会返回任何内容
import Dates from "../models/Date";
import moment from 'moment';
const today = moment().startOf('day').toDate(); // 2018-11-11T22:00:00.000Z
const query = { date_out : { $gte : today }};
router.get("/unavailable", (req, res) => {
Dates.find( query )
.then(Booked_Dates => res.json({ Booked_Dates }))
.catch(err => res.status(400).json({ errors: parseErrors(err.errors) }));
});
还尝试了const query = { date_out : { $gte : 'ISODate("${today}")' }};
'=`
能给我指出正确的方向吗?
PS:如果我删除查询,它将返回正确的结果。
这也是架构:
import mongoose from "mongoose";
const schema = new mongoose.Schema({
user: { type: String, required: true },
date_in: { type: String, required: true },
date_out: { type: String, required: true },
userId: { type: mongoose.Schema.Types.ObjectId, required: true }
});
export default mongoose.model("Date", schema);