ParseRole
public protocol ParseRole : ParseObject
Objects that conform to the ParseRole
protocol represent a Role on the Parse Server.
ParseRole
‘s represent groupings of ParseUser
objects for the purposes of
granting permissions (e.g. specifying a ParseACL
for a ParseObject
).
Roles are specified by their sets of child users and child roles,
all of which are granted any permissions that the parent role has.
Roles must have a name (which cannot be changed after creation of the role),
and must specify a ParseACL
.
-
Gets or sets the name for a role. This value must be set before the role has been saved to the server, and cannot be set once the role has been saved.
Warning
A role’s name can only contain alphanumeric characters,_
,-
, and spaces.Declaration
Swift
var name: String? { get set }
-
users
Default implementationGets the
ParseRelation
for theParseUser
objects that are direct children of this role. These users are granted any privileges that this role has been granted (e.g. read or write access throughParseACL
s). You can add or remove users from the role through this relation.Default Implementation
Declaration
Swift
var users: ParseRelation<Self>? { get }
-
roles
Default implementationGets the
ParseRelation
for theParseRole
objects that are direct children of this role. These roles’ users are granted any privileges that this role has been granted (e.g. read or write access throughParseACL
s). You can add or remove child roles from this role through this relation.Default Implementation
Declaration
Swift
var roles: ParseRelation<Self>? { get }
-
Create a an empty
ParseRole
.Warning
It’s best to use the provided initializers,init(name: String)
orinit(name: String, acl: ParseACL)
instead ofinit()
as they ensure theParseRole
is setup properly.Declaration
Swift
init()
-
init(name:
Default implementation) Create a
ParseRole
with a name. TheParseACL
will still need to be initialized before saving.Throws
An error of typeParseError
if the name has invalid characters.Default Implementation
Declaration
Swift
init(name: String) throws
Parameters
name
The name of the Role to create.
-
init(name:
Default implementationacl: ) Create a
ParseRole
with a name.Throws
An error of typeParseError
if the name has invalid characters.Default Implementation
Declaration
Swift
init(name: String, acl: ParseACL) throws
Parameters
name
The name of the Role to create.
acl
The
ParseACL
for this role. Roles must have an ACL. AParseRole
is a local representation of a role persisted to the Parse Server.
-
className
Extension methodDeclaration
Swift
static var className: String { get }
-
==(_:
Extension method_: ) Declaration
Swift
static func == (lhs: Self, rhs: Self) -> Bool
-
hash(into:
Extension method) Declaration
Swift
func hash(into hasher: inout Hasher)
-
queryRoles()
Extension methodQuery the
ParseRelation
for theParseRole
‘s that are direct children of this role. These users are granted any privileges that this role has been granted (e.g. read or write access throughParseACL
s).Throws
An error of typeParseError
.Declaration
Swift
func queryRoles() throws -> Query<Self>
Return Value
An instance of query for easy chaining.
-
queryUsers()
Extension methodQuery the
ParseRelation
for theParseUser
‘s that are direct children of this role. These users are granted any privileges that this role has been granted (e.g. read or write access throughParseACL
s).Throws
An error of typeParseError
.Declaration
Swift
func queryUsers() throws -> Query<RoleUser>
Return Value
An instance of query for easy chaining.