/**
- Demonstration of Mingo Integration in Memory Driver
- This file shows how ObjectQL filters are converted to MongoDB queries
- and processed by Mingo for in-memory data. */
// Example filter conversions:
/**
- Example 1: Simple Equality
- ObjectQL Filter:
- [['role', '=', 'admin']]
- Converts to MongoDB Query:
- { role: 'admin' } */
/**
- Example 2: Comparison Operators
- ObjectQL Filter:
- [['age', '>', 30]]
- Converts to MongoDB Query:
- { age: { $gt: 30 } } */
/**
- Example 3: OR Logic
- ObjectQL Filter:
- [
- ['role', '=', 'admin'],
- 'or',
- ['age', '>', 30]
- ]
- Converts to MongoDB Query:
- {
- $or: [
-
{ role: 'admin' }, -
{ age: { $gt: 30 } } - ]
- } */
/**
- Example 4: AND Logic (Multiple Conditions)
- ObjectQL Filter:
- [
- ['status', '=', 'active'],
- 'and',
- ['role', '=', 'user']
- ]
- Converts to MongoDB Query:
- {
- $and: [
-
{ status: 'active' }, -
{ role: 'user' } - ]
- } */
/**
- Example 5: String Contains (Case-Insensitive)
- ObjectQL Filter:
- [['name', 'contains', 'john']]
- Converts to MongoDB Query:
- { name: { $regex: /john/i } } */
/**
- Example 6: IN Operator
- ObjectQL Filter:
- [['status', 'in', ['active', 'pending']]]
- Converts to MongoDB Query:
- { status: { $in: ['active', 'pending'] } } */
/**
- Example 7: Between Range
- ObjectQL Filter:
- [['age', 'between', [25, 35]]]
- Converts to MongoDB Query:
- { age: { $gte: 25, $lte: 35 } } */
/**
- Implementation Details:
- The MemoryDriver now uses:
-
- convertToMongoQuery(filters) - Converts ObjectQL filters to MongoDB query
-
- new Query(mongoQuery) - Creates a Mingo query instance
-
- query.find(records).all() - Executes query and returns matching records
- This provides:
-
- MongoDB-compatible query semantics
-
- High performance in-memory queries
-
- Rich operator support
-
- Consistent behavior with MongoDB
- All while maintaining 100% backward compatibility with existing ObjectQL code! */
console.log('Mingo Integration Demo - See comments in file for query conversion examples');