Skip to content

Commit 658b9cf

Browse files
(DOCSP-36260): Use isNumber in filter examples (#6217) (#6237)
* (DOCSP-36260): Use isNumber in filter examples * fix line highlights
1 parent 7c1e372 commit 658b9cf

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
@@ -101,27 +101,21 @@ Behavior
101101
$filter: {
102102
input: [ 1, "a", 2, null, 3.1, NumberLong(4), "5" ],
103103
as: "num",
104-
cond: { $and: [
105-
{ $gte: [ "$$num", NumberLong("-9223372036854775807") ] },
106-
{ $lte: [ "$$num", NumberLong("9223372036854775807") ] }
107-
] }
104+
cond: { $isNumber: "$$num" }
108105
}
109106
}
110107

111108
- ``[ 1, 2, 3.1, NumberLong(4) ]``
112109

113110
* - .. code-block:: javascript
114111
:copyable: false
115-
:emphasize-lines: 9
112+
:emphasize-lines: 6
116113

117114
{
118115
$filter: {
119116
input: [ 1, "a", 2, null, 3.1, NumberLong(4), "5" ],
120117
as: "num",
121-
cond: { $and:[
122-
{ $gte: [ "$$num", NumberLong("-9223372036854775807") ] },
123-
{ $gte: [ "$$num", NumberLong("9223372036854775807") ] }
124-
] }
118+
cond: { $isNumber: "$$num" },
125119
limit: 2
126120
}
127121
}
@@ -130,17 +124,14 @@ Behavior
130124

131125
* - .. code-block:: javascript
132126
:copyable: false
133-
:emphasize-lines: 9
127+
:emphasize-lines: 6
134128

135129
{
136130
$filter: {
137131
input: [ 1, "a", 2, null, 3.1, NumberLong(4), "5" ],
138132
as: "num",
139-
cond: { $and:[
140-
{ $gte: [ "$$num", NumberLong("-9223372036854775807") ] },
141-
{ $gte: [ "$$num", NumberLong("9223372036854775807") ] }
142-
] }
143-
limit: { $add: [ 0, 1 ]}
133+
cond: { $isNumber: "$$num" },
134+
limit: { $add: [ 0, 1 ] }
144135
}
145136
}
146137

0 commit comments

Comments
 (0)