Class: Parse::Constraint::ReadableByConstraint
- Inherits:
-
Parse::Constraint
- Object
- Parse::Constraint
- Parse::Constraint::ReadableByConstraint
- Includes:
- AclConstraintHelpers
- Defined in:
- lib/parse/query/constraints.rb
Overview
This constraint uses aggregation pipeline because Parse Server restricts direct queries on the internal _rperm field.
ACL Read Permission Query Constraint Query objects based on read permissions using MongoDB's internal _rperm field. Parse Server restricts direct queries on _rperm, so this uses aggregation pipeline.
Instance Attribute Summary
Attributes inherited from Parse::Constraint
#operand, #operation, #operator, #value
Instance Method Summary collapse
-
#build ⇒ Hash
The compiled constraint using aggregation pipeline.
-
#readable_by ⇒ ReadableByConstraint
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.
3086 3087 3088 3089 3090 3091 3092 3093 3094 3095 3096 3097 3098 3099 3100 3101 3102 3103 3104 3105 3106 3107 3108 3109 3110 3111 3112 3113 3114 3115 |
# File 'lib/parse/query/constraints.rb', line 3086 def build keys = normalize_acl_keys(@value) if keys.empty? # Empty array = no read permissions (master key only) # Match documents where _rperm is an empty array pipeline = [ { "$match" => { "$or" => [ { "_rperm" => { "$exists" => true, "$eq" => [] } }, { "_rperm" => { "$exists" => false } }, ], }, }, ] else # Find objects readable by ANY of the specified keys # Use $in to match if _rperm contains any of the keys pipeline = [ { "$match" => { "_rperm" => { "$in" => keys }, }, }, ] end { "__aggregation_pipeline" => pipeline } end |
#readable_by ⇒ ReadableByConstraint
A registered method on a symbol to create the constraint. NOTE: :readable_by is already registered by ACLReadableByConstraint above. This class provides simplified empty ACL queries and is used internally.
|
|
# File 'lib/parse/query/constraints.rb', line 3075
|