Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
1.3k views
in Technique[技术] by (71.8m points)

node.js - ISODate is not defined

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); 
});

Error: ISODate is not defined

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

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.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...