本文介绍了未定义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 is not defined
推荐答案
请注意,ISODate
是MongoDB的一部分,在您的情况下不可用.您应该使用Date
代替,MongoDB驱动程序(例如您当前正在使用的Mongoose ORM)将负责幕后Date
和ISODate
之间的类型转换.
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的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!