ISODate 未定义 [英] ISODate is not defined
本文介绍了ISODate 未定义的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在尝试使用 nodejs/mongoose 从 mongodb 获取结果.
I am trying to get results from mongodb using nodejs/mongoose.
var dateStr = new Date(year,month,day,0,0,0);
var nextDate = new Date(year,month,day,23,59,59);
GPSData.find({"createdAt" : { $gte : new ISODate(dateStr), $lte: new ISODate(nextDate) }}, function(err, data) {
if(err)
console.log(err);
});
错误:ISODate 未定义
推荐答案
请注意,ISODate
是 MongoDB 的一部分,在您的情况下不可用.您应该使用 Date
而 MongoDB 驱动程序(例如您当前使用的 Mongoose ORM)将负责 Date
和 ISODate<之间的类型转换/code> 在幕后.
Note that ISODate
is a part of MongoDB and is not available in your case. You should be using Date
instead and the MongoDB drivers(e.g. the Mongoose ORM that you are currently using) will take care of the type conversion between Date
and ISODate
behind the scene.
这篇关于ISODate 未定义的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文