ClassPrivileges

public struct ClassPrivileges : OptionSet, CustomDebugStringConvertible

A description of the actual privileges which apply to a Class within a Realm.

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(ObjectClass.self) or realm.getPrivileges(forClassNamed: "className")

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)
  • If false, the current User is not permitted to see objects of this type, and attempting to query this class will always return empty results.

    Note that Read permissions are transitive, and so it may be possible to read an object which the user does not directly have Read permissions for by following a link to it from an object they do have Read permissions for. This does not apply to any of the other permission types.

    Declaration

    Swift

    public static let read: ClassPrivileges
  • If false, creating new objects of this type is not permitted. Write transactions creating objects can be performed locally, but the objects will be deleted by the server when synchronization occurs.

    For objects with Primary Keys, it may not be locally determinable if Create or Update privileges are applicable. It may appear that you are creating a new object, but an object with that Primary Key may already exist and simply not be visible to you, in which case it is actually an Update operation. Deleting an object is considered a modification, and is governed by this privilege.

    Declaration

    Swift

    public static let create: ClassPrivileges
  • If false, no modifications to objects of this type are permitted. Write transactions modifying the objects can be performed locally, but any changes made will be reverted by the server.

    Deleting an object is considered a modification, and is governed by this privilege.

    Declaration

    Swift

    public static let update: ClassPrivileges
  • If false, the User is not permitted to create new subscriptions for this class. Local queries against the objects within the Realm will work, but new subscriptions will never add objects to the Realm.

    Declaration

    Swift

    public static let subscribe: ClassPrivileges
  • If false, no modifications to the permissions property of the RLMClassPermissions object for this type are permitted. Write transactions can be performed locally, but any changes made will be reverted by the server.

    Note that if invalid privilege changes are made, -[Realm privilegesFor*:] will return results reflecting those invalid changes until synchronization occurs.

    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: ClassPrivileges