官术网_书友最值得收藏!

Data types

MongoDB uses BSON, a binary-encoded serialization for JSON documents. BSON extends on JSON data types offering for example, native date and binary data types.

BSON, compared to protocol buffers, allows for more flexible schemas that come at the cost of space efficiency. In general, BSON is space efficient, easy to traverse, and time-efficient in encoding/decoding operations.

MongoDB Documentation https://docs.mongodb.com/manual/reference/bson-types/

In MongoDB, we can have documents with different value types for a given field and distinguish among them in querying using the $type operator.

For example, if we have a balance field in GBP with 32-bit integers and double data types, if the balance has pennies in it or not, we can easily query for all accounts that have a rounded balance with any of the following queries:

db.account.find( { "balance" : { $type : 16 } } );
db.account.find( { "balance" : { $type : "integer" } } );
主站蜘蛛池模板: 西充县| 齐河县| 德清县| 西贡区| 乐陵市| 海口市| 奎屯市| 瑞安市| 锦州市| 榆树市| 历史| 普定县| 外汇| 满城县| 万荣县| 章丘市| 哈巴河县| 营口市| 乐昌市| 巩留县| 韶山市| 黑河市| 南和县| 定南县| 宣威市| 盘山县| 朝阳市| 锦屏县| 剑河县| 肃北| 徐水县| 揭东县| 孟津县| 德州市| 山东省| 平南县| 从化市| 潜山县| 华阴市| 厦门市| 赤水市|