Mongo使用,mongo

來源:互聯網
上載者:User

Mongo使用,mongo
在用mongo進行查詢時,$exists表示是否document是否包含這個field,即使field的value為null也算是包含。

$existsSyntax: { field: { $exists: <boolean> } }When <boolean> is true, $exists matches the documents that contain the field, including documents where the field value is null. If <boolean> is false, the query returns only the documents that do not contain the field.ExamplesExists and Not Equal ToConsider the following example:db.inventory.find( { qty: { $exists: true, $nin: [ 5, 15 ] } } )This query will select all documents in the inventory collection where the qty field exists and its value does not equal 5 or 15.Null ValuesGiven a collection named records with the following documents:{ a: 5, b: 5, c: null }{ a: 3, b: null, c: 8 }{ a: null, b: 3, c: 9 }{ a: 1, b: 2, c: 3 }{ a: 2, c: 5 }{ a: 3, b: 2 }{ a: 4 }{ b: 2, c: 4 }{ b: 2 }{ c: 6 }Consider the output of the following queries:Query: db.records.find( { a: { $exists: true } } )Result: { a: 5, b: 5, c: null }{ a: 3, b: null, c: 8 }{ a: null, b: 3, c: 9 }{ a: 1, b: 2, c: 3 }{ a: 2, c: 5 }{ a: 3, b: 2 }{ a: 4 }Query: db.records.find( { b: { $exists: false } } )Result: { a: 2, c: 5 }{ a: 4 }{ c: 6 }Query: db.records.find( { c: { $exists: false } } )Result: { a: 3, b: 2 }{ a: 4 }{ b: 2 }




而要查看document中哪些field的值為null,則需要用$in 來查詢。詳情可以參考http://docs.mongodb.org/manual/reference/operator/query/in/ 頁面


Mongodb的mongoexport怎使用

mongoexport 不能完成你的要求,,自己寫程式來做吧。
 
使用spring data mongo 多資料來源怎切換 使用註解形式 不影響使用 MongoRepository 介面方案

改成 extends CurbRepository 可以吧
 

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.