Class: Parse::Constraint::NotWriteableByConstraint

Inherits:
Parse::Constraint show all
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 _wperm field.

ACL NOT Writable By Constraint Query objects that are NOT writable by the specified users/roles.

Examples:

Find objects NOT writable by a user

Song.query.where(:acl.not_writeable_by => current_user)

Direct Known Subclasses

NotWritableByConstraint

Instance Attribute Summary

Attributes inherited from Parse::Constraint

#operand, #operation, #operator, #value

Instance Method Summary collapse

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

#buildObject



3199
3200
3201
3202
3203
3204
3205
3206
3207
3208
3209
3210
3211
3212
# File 'lib/parse/query/constraints.rb', line 3199

def build
  keys = normalize_acl_keys(@value)
  return { "__aggregation_pipeline" => [] } if keys.empty?

  pipeline = [
    {
      "$match" => {
        "_wperm" => { "$nin" => keys },
      },
    },
  ]

  { "__aggregation_pipeline" => pipeline }
end