This article demonstrates Some Examples of MongoDB Documents. Since MongoDB is not a relational database system, a MongoDB database doesn’t have tables with rows and columns as usual. Rather, a MongoDB database contains collections. Further, a collection comprises of documents.
The following list provides Some Examples of MongoDB Documents.
At first, consider the following User Document that we can create in MongoDB. As can be seen, there is a unique Object Id. To illustrate, the document has features like name, email, age, address, and interests. However, address attribute is composite. Because it comprises of three attributes -street, city, and state.
{
"_id": ObjectId("5f9d80f0efa12e085f5e5b5c"),
"name": "John Doe",
"email": "johndoe@example.com",
"age": 30,
"address": {
"street": "1 Main St",
"city": "New York",
"state": "NY"
},
"interests": ["reading", "traveling", "music"]
}
Another example is a Blog Post Document. Likewise, it has a unique Object Id. Meanwhile, it has attributes like title, author, content, date_published, and tags. Take the case of tags attribute. Its type is array. In order to read more on MongoDB attribute types, click here.
{
"_id": ObjectId("5f9d819aefa12e085f5e5b5d"),
"title": "How to Write a Blog Post",
"author": "Jane Doe",
"content": "In this blog post, we will discuss the steps involved in writing a blog post...",
"date_published": ISODate("2022-12-01T09:30:00.000Z"),
"tags": ["blogging", "writing", "tips"]
}
Another example is a Product Document. In the similar way, it has a unique Object Id. Among other attributes, there name, manufacturer, price, release_date, and ratings. Furthermore, ratings is an array type attribute. Moreover, it is a composite attribute.
{
"_id": ObjectId("5f9d825aefa12e085f5e5b5e"),
"name": "Apple iPhone X",
"manufacturer": "Apple Inc.",
"price": 999.99,
"release_date": ISODate("2017-11-03T00:00:00.000Z"),
"ratings": [
{
"user": "John Doe",
"rating": 4.5,
"review": "Good product with great features"
},
{
"user": "Jane Doe",
"rating": 4.0,
"review": "Nice phone with a good camera"
}
]
}
These are just examples and the structure of the documents in a MongoDB collection can vary depending on the requirements of your application. In fact, MongoDB has a wide range of applications. The following list provides some of the applications.
- Content Management System
- E-Commerce Applications
- Business Intelligence
- Analytics
- Gaming applications
In general, these are just a few examples, and MongoDB’s wide range of features and scalability make it a suitable choice for many other types of applications as well.
Useful Links
Alternatives of MERN Stack
Further Reading
Creating Single Page Applications with Angular
Angular 10 Data Binding in Different Ways
Creating Some Angular Components
Examples of Array Functions in PHP
- AI
- Android
- Angular
- ASP.NET
- Augmented Reality
- AWS
- Bioinformatics
- Biometrics
- Blockchain
- Bootstrap
- C
- C#
- C++
- Cloud Computing
- Competitions
- Courses
- CSS
- Cyber Security
- Data Science
- Data Structures and Algorithms
- Data Visualization
- Datafication
- Deep Learning
- DevOps
- Digital Forensic
- Digital Trust
- Digital Twins
- Django
- Docker
- Dot Net Framework
- Drones
- Elasticsearch
- ES6
- Extended Reality
- Flutter and Dart
- Full Stack Development
- Git
- Go
- HTML
- Image Processing
- IoT
- IT
- Java
- JavaScript
- Kotlin
- Latex
- Machine Learning
- MEAN Stack
- MERN Stack
- Microservices
- MongoDB
- NodeJS
- PHP
- Power Bi
- Projects
- Python
- Quantum Computing
- React
- Robotics
- Rust
- Scratch 3.0
- Shell Script
- Smart City
- Software
- Solidity
- SQL
- SQLite
- Tecgnology
- Tkinter
- TypeScript
- VB.NET
- Virtual Reality
- Web Designing
- WebAssembly
- XML