mongodb $where 查詢中的坑


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/


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM