ObjectPrivileges

public struct ObjectPrivileges: OptionSet, CustomDebugStringConvertible

A description of the actual privileges which apply to a specific Object.

This is a combination of all of the privileges granted to all of the Roles which the current User is a member of, obtained by calling realm.getPrivileges(object).

By default, all operations are permitted, and each privilege field indicates an operation which may be forbidden.

  • Declaration

    Swift

    public let rawValue: UInt8
  • Declaration

    Swift

    public init(rawValue: RawValue)

    Parameters

    rawValue
  • If false, the current User is not permitted to read this object directly.

    Objects which cannot be read by a user will appear in a Realm due to that read permissions are transitive. All objects which a readable object links to are themselves implicitly readable. If the link to an object with read=false is removed, the object will be deleted from the local Realm.

    Declaration

    Swift

    public static let read = ObjectPrivileges(rawValue: 1 << 0)
  • If false, modifying the fields of this type is not permitted. Write transactions modifying the objects can be performed locally, but any changes made will be reverted by the server.

    Note that even if this is true, the user may not be able to modify the List<Permission> property of the object (if it exists), as that is governed by setPermissions.

    Declaration

    Swift

    public static let update = ObjectPrivileges(rawValue: 1 << 1)
  • If false, deleting this object is not permitted. Write transactions which delete the object can be performed locally, but the server will restore it.

    It is possible to have update but not delete privileges, or vice versa. For objects with primary keys, delete but not update is ill-advised, as an object can be updated by deleting and recreating it.

    Declaration

    Swift

    public static let delete = ObjectPrivileges(rawValue: 1 << 2)
  • If false, modifying the privileges of this specific object is not permitted.

    Object-specific permissions are set by declaring a List<Permission> property on the Object subclass. Modifications to this property are controlled by setPermissions rather than update.

    Even if this field is true, note that the user will be unable to grant privileges to a Role which they do not themselves have.

    Declaration

    Swift

    public static let setPermissions = ObjectPrivileges(rawValue: 1 << 3)