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.
3115 3116 3117 3118 3119 3120 3121 3122 3123 3124 3125 3126 3127 3128 3129 3130 3131 3132 3133 3134 3135 3136 3137 3138 3139 3140 3141 3142 |
# File 'lib/parse/query/constraints.rb', line 3115 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.
3112 |
# File 'lib/parse/query/constraints.rb', line 3112 register :writeable_by |