1
我想從MongoDB獲取文檔不要有字段"name":"John"
(只是一個示例)。獲取字段不是特定字符串的文檔
我該怎麼做?
爲了得到有現場"name":"John"
我使用的文件:
db.col.find({"name":"John"})
我已經嘗試過...find(!{"name":"John"})
。
我想從MongoDB獲取文檔不要有字段"name":"John"
(只是一個示例)。獲取字段不是特定字符串的文檔
我該怎麼做?
爲了得到有現場"name":"John"
我使用的文件:
db.col.find({"name":"John"})
我已經嘗試過...find(!{"name":"John"})
。
db.col.find({"name":{$ne: "John"}})
應該工作,這裏有文檔:Mongo, Advanced Queries.
只需使用$ne
選擇這樣的:
db.col.find({"name":{$ne:"John"}})