Skip to content

Commit 35e24e2

Browse files
p-mongop
andauthored
MONGOID-4886 Document code w/scope removal from $where in server 4.4 (#4773)
Co-authored-by: Oleg Pudeyev <[email protected]>
1 parent fe70f9d commit 35e24e2

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

source/tutorials/mongoid-queries.txt

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1106,13 +1106,19 @@ Mongoid also has some helpful methods on criteria.
11061106

11071107
* - ``Criteria#for_js``
11081108

1109-
*Find documents for a provided javascript expression. This will
1110-
wrap the javascript in a `BSON::Code` object which is the
1111-
safe way to avoid javascript injection attacks.**
1109+
*Find documents for a provided JavaScript expression, optionally with
1110+
the specified variables added to the evaluation scope. The scope
1111+
argument is supported in MongoDB 4.2 and lower.*
1112+
*In MongoDB 3.6 and higher, prefer* :manual:`$expr
1113+
</reference/operator/query/expr/>` *over* ``for_js``.
11121114

11131115
-
11141116
.. code-block:: ruby
11151117

1118+
# All MongoDB versions
1119+
Band.for_js("this.name = 'Tool'")
1120+
1121+
# MongoDB 4.2 and lower
11161122
Band.for_js("this.name = param", param: "Tool")
11171123

11181124
* - ``Criteria#length|size``

0 commit comments

Comments
 (0)