Skip to content

Commit fd74265

Browse files
(DOCSP-36260): Use isNumber in filter examples (#6217)
* (DOCSP-36260): Use isNumber in filter examples * fix line highlights
1 parent b78b9fd commit fd74265

File tree

1 file changed

+6
-15
lines changed

1 file changed

+6
-15
lines changed

source/reference/operator/aggregation/filter.txt

Lines changed: 6 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -105,27 +105,21 @@ Behavior
105105
$filter: {
106106
input: [ 1, "a", 2, null, 3.1, NumberLong(4), "5" ],
107107
as: "num",
108-
cond: { $and: [
109-
{ $gte: [ "$$num", NumberLong("-9223372036854775807") ] },
110-
{ $lte: [ "$$num", NumberLong("9223372036854775807") ] }
111-
] }
108+
cond: { $isNumber: "$$num" }
112109
}
113110
}
114111

115112
- ``[ 1, 2, 3.1, NumberLong(4) ]``
116113

117114
* - .. code-block:: javascript
118115
:copyable: false
119-
:emphasize-lines: 9
116+
:emphasize-lines: 6
120117

121118
{
122119
$filter: {
123120
input: [ 1, "a", 2, null, 3.1, NumberLong(4), "5" ],
124121
as: "num",
125-
cond: { $and:[
126-
{ $gte: [ "$$num", NumberLong("-9223372036854775807") ] },
127-
{ $lte: [ "$$num", NumberLong("9223372036854775807") ] }
128-
] },
122+
cond: { $isNumber: "$$num" },
129123
limit: 2
130124
}
131125
}
@@ -134,17 +128,14 @@ Behavior
134128

135129
* - .. code-block:: javascript
136130
:copyable: false
137-
:emphasize-lines: 9
131+
:emphasize-lines: 6
138132

139133
{
140134
$filter: {
141135
input: [ 1, "a", 2, null, 3.1, NumberLong(4), "5" ],
142136
as: "num",
143-
cond: { $and:[
144-
{ $gte: [ "$$num", NumberLong("-9223372036854775807") ] },
145-
{ $lte: [ "$$num", NumberLong("9223372036854775807") ] }
146-
] },
147-
limit: { $add: [ 0, 1 ]}
137+
cond: { $isNumber: "$$num" },
138+
limit: { $add: [ 0, 1 ] }
148139
}
149140
}
150141

0 commit comments

Comments
 (0)