Skip to content

Latest commit

 

History

History
327 lines (181 loc) · 6.88 KB

README_AGGREGATIONS.md

File metadata and controls

327 lines (181 loc) · 6.88 KB

EQUALS

Returns a $match aggregation stage

Parameters

  • field String the target field name
  • target unknown the target value

Returns Object an object containing a MongoDb projection object

EQUALS_ALL

Returns a $match aggregation stage for all entries of the object

Parameters

  • object

  • $1 Object (optional, default {})

    • $1.prefix
  • field object the target field name

Returns Object an object containing a MongoDb projection object

EQUALS_ANY_OF

Returns a $in aggregation stage

Parameters

  • field String the target field name
  • targets Array the target values

Returns Object an object containing a MongoDb projection object

EQUALS_WILDCARD

Matches all documents of a collection

Returns Object an object containing a MongoDb match object

LESS_THAN

Returns a $match aggregation stage

Parameters

  • field String the target field name
  • target unknown the target value

Returns Object an object containing a MongoDb projection object

LESS_THAN_OR_EQUAL

Returns a $match aggregation stage

Parameters

  • field String the target field name
  • target unknown the target value

Returns Object an object containing a MongoDb projection object

GREATER_THAN

Returns a $match aggregation stage

Parameters

  • field String the target field name
  • target unknown the target value

Returns Object an object containing a MongoDb projection object

GREATER_THAN_OR_EQUAL

Returns a $match aggregation stage

Parameters

  • field String the target field name
  • target unknown the target value

Returns Object an object containing a MongoDb projection object

LIMIT

Returns a $limit aggregation stage

Parameters

  • amount Number the desired maximum number of elements the query should return

Returns Object an object containing a MongoDb projection object

PROJECT

Returns a $sort aggregation stage

Parameters

Returns Object an object containing a MongoDb projection object

SORT_BY_ASC

Returns a $sort aggregation stage

Parameters

  • field ...String the target field name

Returns Object an object containing a MongoDb projection object

SORT_BY_DESC

Returns a $sort aggregation stage

Parameters

  • field ...String the target field name

Returns Object an object containing a MongoDb projection object

SORT_BY_COUNT

Returns a $sortByCount aggregation stage. Will add required $ prefix to field if missing.

Parameters

  • field String the target field name

Returns Object an object containing a MongoDb projection object

UNWIND

Returns a $unwind aggregation stage. Will add required $ prefix to field if missing.

Parameters

  • field String the target field name

Returns Object an object containing a MongoDb projection object

COUNT

Returns a $count aggregation stage

Returns Object an object containing a MongoDb projection object

LOOKUP

Parameters

  • $0 Object

    • $0.from
    • $0.as
    • $0.localField
    • $0.foreignField (optional, default 'id')
    • $0.pipeline (optional, default [])

Properties

  • from String the collection to lookup from
  • as String name of the merged field
  • localField String local field name
  • foreignField String field name of the from collection
  • pipeline Array pipeline for aggregation of the lookup query

LOOKUP

Parameters

  • options LookupOptions

    • options.from
    • options.as
    • options.localField
    • options.foreignField (optional, default 'id')
    • options.pipeline (optional, default [])

Returns Object

REDUCE

Parameters

  • $0 Object

    • $0.input
    • $0.initialValue (optional, default {})
    • $0.inExpression

Properties

  • input String any expression resolving to an array
  • initialValue any the initial value used for reduction
  • inExpression Object any expression applied to each element of the array

REDUCE

Parameters

  • options ReduceOptions

    • options.input
    • options.initialValue (optional, default {})
    • options.inExpression

Returns Object

APPEND_OBJECTS

Returns a $mergeObjects expression that appends the result of the given expressions to $$value

Parameters

  • expressions ...any a list of expressions that evaluate to an object

Returns Object

LET

Parameters

  • $0 Object

    • $0.vars
    • $0.inExpression

Properties

  • vars Object an object defining additional variables for the expression
  • inExpression Object any expression

LET

Parameters

  • options LetOptions

    • options.vars
    • options.inExpression

TO_OBJECT

Parameters

  • $0 Object

    • $0.key (optional, default '$$this')
    • $0.value

Properties

  • key String the object key
  • expression Object any expression

TO_OBJECT

Parameters

  • options ToObjectOptions

    • options.key (optional, default '$$this')
    • options.value

CONCAT_STRINGS

Parameters

  • strings ...any strings to concat

Returns Object

JOIN_STRINGS

Parameters

  • separator String separator to be used for joining given strings
  • strings ...any strings to concat

Returns Object

CONCAT_ARRAYS

Returns Object

ELEMENT_AT

Parameters

Returns Object

AS_ROOT

Parameters

  • fieldName String the field to return as root

Returns Object

EXISTS

Parameters

  • fieldName String the field to check for existence

INDEX_STATS

Returns Object