Class: Parse::Constraint::ReadableByConstraint
- Inherits:
-
Constraint
- Object
- Constraint
- Parse::Constraint::ReadableByConstraint
- Includes:
- AclConstraintHelpers
- Defined in:
- lib/parse/query/constraints.rb
Overview
Note:
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 Method Summary collapse
-
#build ⇒ Hash
The compiled constraint using aggregation pipeline.
-
#readable_by ⇒ ReadableByConstraint
A registered method on a symbol to create the constraint.
Instance Method Details
#build ⇒ Hash
Returns the compiled constraint using aggregation pipeline.
3057 3058 3059 3060 3061 3062 3063 3064 3065 3066 3067 3068 3069 3070 3071 3072 3073 3074 3075 3076 3077 3078 3079 3080 3081 3082 3083 3084 3085 3086 |
# File 'lib/parse/query/constraints.rb', line 3057 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 3046
|