亚洲激情专区-91九色丨porny丨老师-久久久久久久女国产乱让韩-国产精品午夜小视频观看

溫馨提示×

溫馨提示×

您好,登錄后才能下訂單哦!

密碼登錄×
登錄注冊×
其他方式登錄
點擊 登錄注冊 即表示同意《億速云用戶服務條款》

如何進行MongoDB排除查詢$ne缺陷

發布時間:2021-11-03 10:44:33 來源:億速云 閱讀:492 作者:柒染 欄目:關系型數據庫

本篇文章給大家分享的是有關如何進行MongoDB排除查詢$ne缺陷,小編覺得挺實用的,因此分享給大家學習,希望大家閱讀完這篇文章后可以有所收獲,話不多說,跟著小編一起來看看吧。

    最近學習MongoDB數據庫基本開發知識,發現MongoDB的排除查$ne類似于Oracle的not in 或者not exists,

但是$ne只能對字符串鍵值對起作用而對數字類型不行,舉例如下:

示例數據:

> dvd=({"Type":"DVD","Title":"Matrix,The","Released":1999,"Cast":["Keanu Reeeves","Carrie-Anne Moss","Laurence Fishburne","Hugo Weaving","Gloria Foster","Joe Pantoliano"]})

{

"Type" : "DVD",

"Title" : "Matrix,The",

"Released" : 1999,

"Cast" : [

"Keanu Reeeves",

"Carrie-Anne Moss",

"Laurence Fishburne",

"Hugo Weaving",

"Gloria Foster",

"Joe Pantoliano"

]

}

> db.media.insert(dvd)

WriteResult({ "nInserted" : 1 })

> dvd=({"Type":"DVD","Title":"Blade Runner","Released":1982})

{ "Type" : "DVD", "Title" : "Blade Runner", "Released" : 1982 }

> db.media.insert(dvd)

WriteResult({ "nInserted" : 1 })

> dvd=({"Type":"DVD","Title":"Toy Story 3","Released":2010})

{ "Type" : "DVD", "Title" : "Toy Story 3", "Released" : 2010 }

> db.media.insert(dvd)

WriteResult({ "nInserted" : 1 })

>

正常的字符串排除查詢,以示例數據中Title鍵進行測試:

> db.media.find({"Type":"DVD","Title":{$ne:"Blade Runner"}})

{ "_id" : ObjectId("595af5ce39297105e4322fbd"), "Type" : "DVD", "Title" : "Matrix,The", "Released" : 1999, "Cast" : [ "Keanu Reeeves", "Carrie-Anne Moss", "Laurence Fishburne", "Hugo Weaving", "Gloria Foster", "Joe Pantoliano" ] }

{ "_id" : ObjectId("595af63239297105e4322fbf"), "Type" : "DVD", "Title" : "Toy Story 3", "Released" : 2010 }

>

對數字排除無效,以示例數據中Released鍵進行測試:

> db.media.find({"Type":"DVD","Release":{$ne:"1999"}})

{ "_id" : ObjectId("595af5ce39297105e4322fbd"), "Type" : "DVD", "Title" : "Matrix,The", "Released" : 1999, "Cast" : [ "Keanu Reeeves", "Carrie-Anne Moss", "Laurence Fishburne", "Hugo Weaving", "Gloria Foster", "Joe Pantoliano" ] }

{ "_id" : ObjectId("595af61939297105e4322fbe"), "Type" : "DVD", "Title" : "Blade Runner", "Released" : 1982 }

{ "_id" : ObjectId("595af63239297105e4322fbf"), "Type" : "DVD", "Title" : "Toy Story 3", "Released" : 2010 }

>

> db.media.find({"Type":"DVD","Release":{$ne:1999}})

{ "_id" : ObjectId("595af5ce39297105e4322fbd"), "Type" : "DVD", "Title" : "Matrix,The", "Released" : 1999, "Cast" : [ "Keanu Reeeves", "Carrie-Anne Moss", "Laurence Fishburne", "Hugo Weaving", "Gloria Foster", "Joe Pantoliano" ] }

{ "_id" : ObjectId("595af61939297105e4322fbe"), "Type" : "DVD", "Title" : "Blade Runner", "Released" : 1982 }

{ "_id" : ObjectId("595af63239297105e4322fbf"), "Type" : "DVD", "Title" : "Toy Story 3", "Released" : 2010 }

>

實驗結果:mongodb的$ne操作只能對字符串鍵值對發揮作用。

本次實驗的MongoDB數據庫版本是:3.2.7

以上就是如何進行MongoDB排除查詢$ne缺陷,小編相信有部分知識點可能是我們日常工作會見到或用到的。希望你能通過這篇文章學到更多知識。更多詳情敬請關注億速云行業資訊頻道。

向AI問一下細節

免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。

AI

托克托县| 新平| 栾城县| 沐川县| 龙游县| 遂昌县| 精河县| 梁平县| 沧州市| 日土县| 望奎县| 玛曲县| 沽源县| 四子王旗| 旺苍县| 女性| 凌海市| 长丰县| 广水市| 若尔盖县| 赤峰市| 上虞市| 巴东县| 宁都县| 章丘市| 南阳市| 万载县| 大宁县| 塘沽区| 简阳市| 湛江市| 杭锦旗| 奉节县| 当涂县| 桓仁| 钦州市| 宁都县| 平罗县| 宜昌市| 黔南| 南京市|