Skip to content

Commit

Permalink
Add $isNumber aggregation operator
Browse files Browse the repository at this point in the history
  • Loading branch information
zarathustra323 committed Dec 11, 2024
1 parent f785c2c commit f9032b7
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions packages/aggregation/src/operators.js
Original file line number Diff line number Diff line change
Expand Up @@ -399,6 +399,24 @@ export class AggregationOperators {
return { $isArray: [expression] };
}

/**
* `$isNumber` checks if the specified expression resolves to one of the following numeric BSON
* types:
* - Integer
* - Decimal
* - Double
* - Long
*
* `$isNumber` returns:
* - `true` if the expression resolves to a number.
* - `false` if the expression resolves to any other BSON type, `null`, or a missing field.
*
* @param {Expression<any>} expression
*/
static $isNumber(expression) {
return { $isNumber: [expression] };
}

static $last(expression) {
return { $last: expression };
}
Expand Down

0 comments on commit f9032b7

Please sign in to comment.