- 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.
推薦閱讀
- Java Web基礎與實例教程(第2版·微課版)
- Xcode 7 Essentials(Second Edition)
- Selenium Design Patterns and Best Practices
- Dependency Injection in .NET Core 2.0
- Silverlight魔幻銀燈
- 人人都懂設計模式:從生活中領悟設計模式(Python實現)
- Hands-On Microservices with Kotlin
- 大模型RAG實戰:RAG原理、應用與系統構建
- 量化金融R語言高級教程
- 好好學Java:從零基礎到項目實戰
- Python 3.7從入門到精通(視頻教學版)
- Azure Serverless Computing Cookbook
- Red Hat Enterprise Linux Troubleshooting Guide
- Everyday Data Structures
- Illustrator CS6設計與應用任務教程