File tree Expand file tree Collapse file tree 1 file changed +9
-3
lines changed Expand file tree Collapse file tree 1 file changed +9
-3
lines changed Original file line number Diff line number Diff 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``
You can’t perform that action at this time.
0 commit comments