91超碰碰碰碰久久久久久综合_超碰av人澡人澡人澡人澡人掠_国产黄大片在线观看画质优化_txt小说免费全本

溫馨提示×

溫馨提示×

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

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

如何進行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

凌云县| 揭阳市| 永年县| 来凤县| 南宁市| 鹤山市| 兴业县| 淮南市| 紫云| 乐至县| 舟山市| 香河县| 临高县| 平潭县| 合阳县| 乐清市| 金昌市| 兰州市| 乐平市| 祁阳县| 仁寿县| 青河县| 隆尧县| 柏乡县| 寿阳县| 怀来县| 精河县| 酒泉市| 两当县| 平武县| 新宁县| 东海县| 正镶白旗| 高清| 保康县| 双鸭山市| 尉犁县| 西林县| 徐州市| 罗平县| 敦化市|