mongodb 查詢中坑就是數字開頭的字段不能用點號,只能用[""]。例如:
即:db.datas.find({$where:"this['54bcfc6c329af61034f7c2fc'].testRet !== this['54bcfc6c329af61034f7c2fc'].taskRet"})
但是 如果你用
即:db.datas.find({$where:"this.54bcfc6c329af61034f7c2fc.testRet !== this.54bcfc6c329af61034f7c2fc.taskRet"})
查詢時會報錯
Error: error: { "ok" : 0, "errmsg" : "Failed to call method", "code" : 1 }
mongodb $where 的用法詳見mongodb官網:
https://docs.mongodb.com/manual/reference/operator/query/where/