- Document-Oriented: Data is stored in flexible JSON-like documents called BSON.
- Dynamic Schema: Supports dynamic schema for easy data storage and retrieval.
- High Scalability: Allows horizontal scaling by distributing data across multiple servers.
- Query Language: Provides a rich query language for data retrieval and manipulation.
- Abstraction of Database Complexity: Hides database-specific details from application code.
- Simplified CRUD Operations: Provides methods for creating, reading, updating, and deleting data.
- Object-Oriented Approach: Allows developers to work with objects instead of raw SQL queries.
- Schema Definition: Defines data models with defined properties and data types.
- Middleware Support: Allows pre and post-processing of data before and after operations.
- Query Building: Provides methods for CRUD operations and advanced querying.
- Validation: Offers built-in validators for data validation.
Getting Started with Mongoose:
-
Installation: Install Mongoose via npm or yarn.
npm install mongoose
-
Connecting to MongoDB: Set up a connection to your MongoDB database.
const mongoose = require('mongoose'); mongoose.connect('mongodb://localhost:27017/mydatabase', { useNewUrlParser: true, useUnifiedTopology: true });
- Structured Data Storage: Stores data in tables with a predefined schema.
- SQL Query Language: Uses SQL for querying and manipulation.
- ACID Properties: Enforces Atomicity, Consistency, Isolation, Durability for data integrity.
- Relationships: Supports complex relationships between tables.
- Flexible Data Storage: Stores data in flexible formats like documents, key-value pairs, or wide-column stores.
- Query Languages Vary: NoSQL databases use different query languages (e.g., MongoDB's BSON).
- Scalability and Performance: Offers scalability and high performance, suitable for large volumes of unstructured data.
- Lack of ACID Properties: Emphasizes eventual consistency and scalability over strict consistency models.