db.command.lte在云服务端不能比较Date吗?
发布于 7 年前 作者 weilong 11787 次浏览 来自 官方Issues
2 回复

比较Date用  db.command.aggregate.lte

https://developers.weixin.qq.com/miniprogram/dev/wxcloud/reference-server-api/database/aggregation/operators/lte.html

查询字段 time <= 2019-10-01的记录,time必须是数据库Date类型

const $ = db.command.aggregate

var d = new Date('2019-10-01'),

a = $.dateFromString({

    dateString: d.toJSON()

})

db.collection('xxx').aggregate()

.addFields({

    matched: $.lte(['$time', a]),

})

.match({

    matched:!0

})

.end()

回到顶部