Skip to content

What is the correct way to query a Role? #44

Answered by cbaker6
vdkdamian asked this question in Q&A
Discussion options

You must be logged in to vote

The playgrounds has examples of how to use most of the features:

/*:
To retrieve the users who are all Administrators,
we need to query the relation.
*/
do {
let query: Query<User>? = try savedRole!.users?.query()
query?.find { result in
switch result {
case .success(let relatedUsers):
print("""
The following users are part of the
\"\(String(describing: savedRole!.name)) role: \(relatedUsers)
""")
case .failure(let error):
print("Error querying role: \(error)")
}
}

Replies: 1 comment 6 replies

Comment options

You must be logged in to vote
6 replies
@vdkdamian
Comment options

@cbaker6
Comment options

@vdkdamian
Comment options

@cbaker6
Comment options

@vdkdamian
Comment options

Answer selected by vdkdamian
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants