- Web Development with MongoDB and Node(Third Edition)
- Bruno Joseph D'mello Mithun Satheesh Jason Krol
- 157字
- 2021-07-08 10:32:38
JSON-friendly database
One of the most important reasons for the popularity of MongoDB is that it is a JSON-friendly database. This means that documents are stored and retrieved from MongoDB as JavaScript objects. Internally, this JSON data gets converted to BSON format while getting persisted to the system. So, this gives extreme flexibility, where we can use the same data format from client to server and eventually to the database.
A typical document (record) in a MongoDB collection (table) might look like the following code:
$ mongo
> db.contacts.find({email: 'jason@kroltech.com'}).pretty()
{
"email" : "jason@kroltech.com",
"phone" : "123-456-7890",
"gravatar" : "751e957d48e31841ff15d8fa0f1b0acf",
"_id" : ObjectId("52fad824392f58ac2452c992"),
"name" : {
"first" : "Jason",
"last" : "Krol"
},
"__v" : 0
}
After examining the preceding output, we can see a key called _id. It is a MongoDB ID which must be encoded as a binary JSON objectID(BSON). If failed to encode, MongoDB won't be able to retrieve or update an object.
推薦閱讀
- PHP動態網站程序設計
- 多媒體CAI課件設計與制作導論(第二版)
- SQL Server 2012數據庫技術及應用(微課版·第5版)
- 算法訓練營:入門篇(全彩版)
- Building Mobile Applications Using Kendo UI Mobile and ASP.NET Web API
- Java Web開發就該這樣學
- 搞定J2EE:Struts+Spring+Hibernate整合詳解與典型案例
- Django 3.0入門與實踐
- Rust游戲開發實戰
- Web App Testing Using Knockout.JS
- Java Web從入門到精通(第2版)
- Mastering Gephi Network Visualization
- Get Your Hands Dirty on Clean Architecture
- 一步一步學Spring Boot:微服務項目實戰(第2版)
- Building Web and Mobile ArcGIS Server Applications with JavaScript(Second Edition)