mongodb查询语句报错,但看不出哪里有问题,用的navicat 12 for mongodb 连接执行的。(刚接触mongodb)
目的就是查询carordershands集合中created日期是20220830之后且coalInform不为空的信息,按照created降序排列
db.getCollection("carordershands").find(
{
"created": {
'$lt': new Date(2022, 08, 30)
}
},
{
"coalInform": {
'$ne': null
}
}
).sort({
"created": - 1
})
[Error] Expression $ne takes exactly 2 arguments. 1 were passed in.
at line 0, column 0
尝试写成如下
db.getCollection("carordershands").find({
{
"created": {
'$lt': new Date(2022, 08, 30)
}
},
{
"coalInform": {
'$ne': null
}
}
}).sort({
"created": - 1
})
执行依旧报错:
[Error] SyntaxError: invalid property id
at line 2, column 4