Skip to main content

5 posts tagged with "mongodb"

View All Tags

· 4 min read
Sivabharathy

This article evaluates the performance of MongoDB, PostgreSQL (two versions), and CockroachDB in handling data insertion and querying tasks. The comparison is based on how these databases manage workloads, emphasizing time taken for data insertion and query execution.

Reference GitHub Repository: For further insights into BSON and JSON performance, refer to the BSON-JSON Bakeoff repository.


Test Overview

  1. Insertion Test:

    • 10,000 documents with a 4,000-byte (4KB) payload were inserted into an indexed field.
    • Two scenarios were tested:
      • Payload stored in a single attribute.
      • Payload distributed across 200 attributes.
  2. Query Test:

    • Queried 10,000 IDs from an indexed array.
  3. Metrics Measured:

    • Time taken for each operation.
    • Total items retrieved during queries.

· 7 min read
Sivabharathy

When deciding between Prisma and Mongoose for a MongoDB-based application, there are several factors to consider. Both are powerful tools, but they are designed with different paradigms and use cases in mind. Below is a breakdown to help you understand when you might prefer one over the other.

· 4 min read
Sivabharathy

To perform a complete search across all fields in a MongoDB collection using Mongoose, you can leverage MongoDB's powerful querying capabilities. While MongoDB does not natively support searching across all fields in a single query without specifying field names, you can implement a solution by dynamically building queries based on the schema's fields.

· 5 min read
Sivabharathy

Comprehensive Guide to MongoDB Search and Schema Design

MongoDB, a leading NoSQL database, is renowned for its flexibility, scalability, and powerful querying capabilities. Understanding how to effectively design schemas and utilize MongoDB’s search features is essential for leveraging its full potential. This article provides a comprehensive guide to MongoDB search and schema design.

Introduction to MongoDB

MongoDB stores data in a flexible, JSON-like format called BSON (Binary JSON). This format allows for a dynamic schema, enabling documents within a collection to have varying structures. Such flexibility makes MongoDB an ideal choice for applications requiring rapid development and iterative schema design.

· 4 min read
Sivabharathy

Mongoose provides a powerful way to model relationships between documents in your MongoDB collections. Here's an explanation of Mongoose populate with examples for one-to-one, one-to-many, and many-to-many relationships:

1. One-to-One Relationship:

This represents a scenario where a document in one collection can have a reference to at most one document in another collection. Here's an example:

  • User Schema:
const mongoose = require('mongoose');

const userSchema = new mongoose.Schema({
name: String,
profile: {
type: mongoose.Schema.Types.ObjectId,
ref: 'Profile' // Reference to the Profile model
}
});

module.exports = mongoose.model('User', userSchema);