[英]How can I show a date on a kendo datepicker which is less than min date or greater than max date
[英]Mongodb $min value is greater than $max sometimes
我正在从 mongo 数据库中获取日期并返回$first
、 $max
、 $min
和$last
,但是发生了一些非常不寻常的事情 - $min
大于$max
。 这是我的代码:
let Lowestdate = await ETHMongo.aggregate([
{
$match: { createdAt: { $gte: new Date(last), $lte: new Date(NEW) } },
},
{
$group: {
_id: null,
minFee_doc: { $first: "$$ROOT" },
minFee: { $min: "$one" },
firstFee: { $first: "$one" },
lastFee: { $last: "$one" },
maxFee: { $max: "$one" },
},
},
]).then((result) => {});
看起来你的“数字”被保存为string
,在字符串比较中"99" > "1000000"
。
幸运的是,您可以很容易地解决这个问题,只需使用$toInt将字符串转换为数字即可
{
$group: {
_id: null,
minFee_doc: { $first: "$$ROOT" },
minFee: { $min: {$toInt: "$one"} },
firstFee: { $first: "$one" },
lastFee: { $last: "$one" },
maxFee: { $max: {$toInt: "$one"} },
},
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.