MongoDB 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.
npm install @objectql/driver-mongoimport { 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/specquery format - ✅ Smart ID Mapping - Automatic conversion between
id(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
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:
const results = await driver.find('users', {
filters: [['age', '>', 18]],
sort: [['name', 'asc']],
limit: 10,
skip: 0
});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