What you need to know to build your first MongoDB application?
SOLUTION:
MongoDB Terminology
As you build your first application with MongoDB, you should start by knowing some basic terminology. Here are a few key terms and the equivalent concepts in a relational database:
| ||||||||||||
Data as Documents
One of the major benefits of MongoDB is schema flexibility. In MongoDB, there are no predefined fields, collections can have heterogenous structure across documents, and the fields and their value datatypes can vary. For example, here is how you might model a blog post in MongoDB:
{author: "meghan",
date: new Date(),
text: "MongoDB is great!",
tags: ["mongodb", "intro"]}
Querying
Even though MongoDB is a NoSQL database, you can still access your data with dynamic queries. You'll find that many SQL queries translate easily to MongoDB's document-based query language.
For example, suppose we're using the MongoDB shell and want to return every document in the users collection. Our query would look like this:
db.users.find({})
In this case, our selector is an empty document, which matches every document in the collection. Here's a more selective example:
db.users.find({'last_name': 'Smith'})
Here our selector will match every document where the last_name attribute is 'Smith.'
MongoDB supports a wide array of possible document selectors. For more examples:
|
For more information
Interested in learning more about building applications with MongoDB? Here are a few resources to get you started:
- Building your first MongoDB Application
- MongoDB Schema Design: Insights and Tradeoffs from Jetlore
- Docs: MongoDB Tutorial
If you find this solution useful, you are welcome to press one of the ads in this page.. Thanks!
No comments:
Post a Comment