Class: Parse::Constraint::NotWriteableByConstraint

Inherits:
Constraint
  • Object
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 Method Summary collapse

Instance Method Details

#buildObject



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

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

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

  { "__aggregation_pipeline" => pipeline }
end