var curDate = new Date(); var start = new Date((curDate/1000-86400*31)*1000); //console.log(start);结果是 wen jan 20 2016 15:58:12 GMT +0800 <中国标准时间> 反正就是这样一个格式的时间对象 DataStream.find({dataPointKey: dataPoint_id},{"meta.createAt":{$gte:start}}).exec(function (err,dataStreams) { if (err) { console.log(err) } } 数据库的dataStreams的集合部分如下 /* 0 */ { "_id" : ObjectId("569b2691c093eb101b9e54db"), "dataPointKey" : ObjectId("568f48b6d2100c1c09d2ad68"), "meta" : { "updateAt" : ISODate("2016-01-17T05:28:49.734Z"), "createAt" : ISODate("2016-01-17T05:28:49.734Z") }, "value" : 22, "__v" : 0 } /* 1 */ { "_id" : ObjectId("569b2696c093eb101b9e54dc"), "dataPointKey" : ObjectId("568f48b6d2100c1c09d2ad68"), "meta" : { "updateAt" : ISODate("2016-01-17T05:28:54.859Z"), "createAt" : ISODate("2016-01-17T05:28:54.859Z") }, "value" : 44, "__v" : 0 } /* 2 */ { "_id" : ObjectId("569b26a1c093eb101b9e54dd"), "dataPointKey" : ObjectId("568f48b6d2100c1c09d2ad68"), "meta" : { "updateAt" : ISODate("2016-01-17T05:29:05.155Z"), "createAt" : ISODate("2016-01-17T05:29:05.155Z") }, "value" : 45, "__v" : 0 } /* 3 */ { "_id" : ObjectId("569b26a5c093eb101b9e54de"), "dataPointKey" : ObjectId("568f48b6d2100c1c09d2ad68"), "meta" : { "updateAt" : ISODate("2016-01-17T05:29:09.627Z"), "createAt" : ISODate("2016-01-17T05:29:09.627Z") }, "value" : 66, "__v" : 0 } 问题就是 在查询的时候加上时间限制 ,{"meta.createAt":{$gte:start}} 就会提示 不支持的选项, unsupported projection option 求大神解答
julyzhu
相关分类