Method: Mongoid::Criteria#for_js
- Defined in:
- lib/mongoid/criteria.rb
#for_js(javascript, scope = {}) ⇒ Criteria
Find documents by the provided javascript and scope. Uses a $where but is different from Criteria#where in that it will pass a code object to the query instead of a pure string. Safe against Javascript injection attacks.
485 486 487 |
# File 'lib/mongoid/criteria.rb', line 485 def for_js(javascript, scope = {}) js_query(BSON::CodeWithScope.new(javascript, scope)) end |