Class: Parse::Constraint::WriteableByConstraint
- Inherits:
-
Parse::Constraint
- Object
- Parse::Constraint
- Parse::Constraint::WriteableByConstraint
- Includes:
- AclConstraintHelpers
- Defined in:
- lib/parse/query/constraints.rb
Overview
This constraint uses aggregation pipeline because Parse Server restricts direct queries on the internal _wperm field.
ACL Write Permission Query Constraint Query objects based on write permissions using MongoDB's internal _wperm field. Parse Server restricts direct queries on _wperm, so this uses aggregation pipeline.
Direct Known Subclasses
Instance Attribute Summary
Attributes inherited from Parse::Constraint
#operand, #operation, #operator, #value
Instance Method Summary collapse
-
#build ⇒ Hash
The compiled constraint using aggregation pipeline.
-
#writeable_by ⇒ WriteableByConstraint
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 using aggregation pipeline.
3146 3147 3148 3149 3150 3151 3152 3153 3154 3155 3156 3157 3158 3159 3160 3161 3162 3163 3164 3165 3166 3167 3168 3169 3170 3171 3172 3173 |
# File 'lib/parse/query/constraints.rb', line 3146 def build keys = normalize_acl_keys(@value) if keys.empty? # Empty array = no write permissions (master key only) pipeline = [ { "$match" => { "$or" => [ { "_wperm" => { "$exists" => true, "$eq" => [] } }, { "_wperm" => { "$exists" => false } }, ], }, }, ] else # Find objects writable by ANY of the specified keys pipeline = [ { "$match" => { "_wperm" => { "$in" => keys }, }, }, ] end { "__aggregation_pipeline" => pipeline } end |
#writeable_by ⇒ WriteableByConstraint
A registered method on a symbol to create the constraint.
3143 |
# File 'lib/parse/query/constraints.rb', line 3143 register :writeable_by |