Skip to main content
The @feathersjs/mongodb adapter provides native MongoDB integration for Feathers services, supporting all MongoDB features including aggregation pipelines, GridFS, and transactions.

Installation

1

Install dependencies

Install the MongoDB adapter and the MongoDB driver:
2

Connect to MongoDB

Create a MongoDB connection:
3

Create a service

Create a service using the MongoDB adapter:

Configuration

Service Options

The MongoDB adapter accepts these options:

Example Configuration

Querying

Basic Queries

The MongoDB adapter supports all standard Feathers query operators:

MongoDB-Specific Options

Pass native MongoDB options through params.mongodb:

Aggregation Pipelines

Use MongoDB’s powerful aggregation framework with the pipeline parameter:

Data Manipulation

Create

Update

Patch

Remove

ObjectId Handling

The adapter automatically handles ObjectId conversion:

Performance Optimization

Estimated Document Count

For large collections, use estimated count for better performance:

Field Projection

Indexes

Create indexes on your collections:

Type Safety

Full TypeScript support with generics:

Error Handling

The adapter provides specific error handling:

Next Steps

Knex Adapter

Learn about the SQL adapter

Common Patterns

Explore adapter patterns

Hooks

Add hooks to your services

Validation

Validate your data with schemas