MongoDB driver for ObjectQL - Native aggregation pipeline translation for high-performance NoSQL operations
npm install @objectql/driver-mongoMongoDB driver for ObjectQL. Supports basic CRUD, filtering, and aggregation pipelines on MongoDB.
Now with ObjectStack QueryAST support! This driver implements both the legacy Driver interface and the new DriverInterface from @objectstack/spec for seamless integration with the ObjectStack ecosystem.
``bash`
npm install @objectql/driver-mongo
`typescript
import { MongoDriver } from '@objectql/driver-mongo';
const driver = new MongoDriver({
url: 'mongodb://localhost:27017',
dbName: 'my_app'
});
const objectql = new ObjectQL({
datasources: {
default: driver
}
});
`
- ✅ 100% Backward Compatible - All existing code continues to work
- ✅ QueryAST Support - Supports the new @objectstack/spec query formatid
- ✅ Smart ID Mapping - Automatic conversion between (API) and _id (MongoDB)
- ✅ Full-Text Search - MongoDB text search capabilities
- ✅ Array & JSON Fields - Native BSON support for complex data types
- ✅ Aggregation Pipelines - Native MongoDB aggregation support
`typescript`
console.log(driver.name); // 'MongoDriver'
console.log(driver.version); // '3.0.1'
console.log(driver.supports);
// {
// transactions: true,
// joins: false,
// fullTextSearch: true,
// jsonFields: true,
// arrayFields: true
// }
The driver now supports both legacy and QueryAST formats:
typescript
const results = await driver.find('users', {
filters: [['age', '>', 18]],
sort: [['name', 'asc']],
limit: 10,
skip: 0
});
`$3
`typescript
const results = await driver.find('users', {
filters: [['age', '>', 18]],
sort: [{ field: 'name', order: 'asc' }],
top: 10, // Instead of 'limit'
skip: 0
});
``See MIGRATION.md for detailed information about the ObjectStack migration and QueryAST format support.
MIT