Class: Parse::Constraint::DoesNotMatchKeyInQueryConstraint
- Inherits:
-
Parse::Constraint
- Object
- Parse::Constraint
- Parse::Constraint::DoesNotMatchKeyInQueryConstraint
- Defined in:
- lib/parse/query/constraints.rb
Overview
Equivalent to the ‘$dontSelect` Parse query operation but for key matching. This matches objects where a field’s value does NOT equal another field’s value from a different query. This is the inverse of the MatchesKeyInQueryConstraint.
# Find users where user.company does NOT equal customer.company
customer_query = Customer.where(:active => true)
user_query = User.where(:company.does_not_match_key => { key: "company", query: customer_query })
# If the local field has the same name as the remote field, you can omit the key
# assumes key: 'company'
user_query = User.where(:company.does_not_match_key => customer_query)
Instance Attribute Summary
Attributes inherited from Parse::Constraint
#operand, #operation, #operator, #value
Instance Method Summary collapse
-
#build ⇒ Hash
The compiled constraint.
-
#does_not_match_key ⇒ DoesNotMatchKeyInQueryConstraint
Alias for #does_not_match_key_in_query.
-
#does_not_match_key_in_query ⇒ DoesNotMatchKeyInQueryConstraint
A registered method on a symbol to create the constraint.
Methods inherited from Parse::Constraint
#as_json, constraint_keyword, create, formatted_value, #formatted_value, #initialize, #key, #precedence, register, #to_s
Constructor Details
This class inherits a constructor from Parse::Constraint
Instance Method Details
#build ⇒ Hash
Returns the compiled constraint.
2264 2265 2266 2267 2268 2269 2270 2271 2272 2273 2274 2275 2276 2277 2278 2279 2280 2281 2282 2283 2284 |
# File 'lib/parse/query/constraints.rb', line 2264 def build remote_field_name = @operation.operand query = nil if @value.is_a?(Hash) res = @value.symbolize_keys remote_field_name = res[:key] || remote_field_name query = res[:query] unless query.is_a?(Parse::Query) raise ArgumentError, "Invalid Parse::Query object provided in :query field of value: #{@operation.operand}.does_not_match_key_in_query => #{@value}" end query = query.compile(encode: false, includeClassName: true) elsif @value.is_a?(Parse::Query) # if its a query, then assume key is the same name as operand. query = @value.compile(encode: false, includeClassName: true) else raise ArgumentError, "Invalid `:does_not_match_key_in_query` query constraint. It should follow the format: :field.does_not_match_key_in_query => { key: 'key', query: '<Parse::Query>' }" end { @operation.operand => { :$dontSelect => { key: remote_field_name, query: query } } } end |
#does_not_match_key ⇒ DoesNotMatchKeyInQueryConstraint
Alias for #does_not_match_key_in_query
2259 |
# File 'lib/parse/query/constraints.rb', line 2259 constraint_keyword :$dontSelect |
#does_not_match_key_in_query ⇒ DoesNotMatchKeyInQueryConstraint
A registered method on a symbol to create the constraint.
|
|
# File 'lib/parse/query/constraints.rb', line 2249
|