Supporting Aggregate and other operators #924
psicomante
started this conversation in
General
Replies: 1 comment 2 replies
-
Hi @psicomante, currently SignalDB doesn't support the aggregation framework, as it would add too much complexity and also is a bit out of scope of the core functionality. Maybe I'll add support some day, but it's not planned right now. Example (not tested, but should work kind of like this): import { Collection } from 'signaldb'
import { Aggregator } from 'mingo/aggregator'
import { useOperators, OperatorType } from 'mingo/core'
import { $match, $group } from 'mingo/operators/pipeline'
import { $min } from 'mingo/operators/accumulator'
// ensure the required operators are preloaded prior to using them.
useOperators(OperatorType.PIPELINE, { $match, $group })
useOperators(OperatorType.ACCUMULATOR, { $min })
const agg = new Aggregator([
{ $match: { type: 'homework' } },
{ $group: { _id: '$student_id', score: { $min: '$score' } } },
{ $sort: { _id: 1, score: 1 } },
])
const collection = new Collection()
const result = agg.run(collection.find().fetch()) |
Beta Was this translation helpful? Give feedback.
2 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Hello Max,
I have another question about operators supported in Mingo. Am i wrong or aggregate selectors like:
are not yet supported?
If there is no way to use this type of selector inside Signaldb, do you plan to add support for it?
Beta Was this translation helpful? Give feedback.
All reactions