Skip to content

Instantly share code, notes, and snippets.

@vikdenic
Created April 10, 2016 21:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save vikdenic/335326c147c753fa86f8be6819865541 to your computer and use it in GitHub Desktop.
Save vikdenic/335326c147c753fa86f8be6819865541 to your computer and use it in GitHub Desktop.
class func retrieveAllUsers(withNameLike name : String, completed : ((users : [BackendlessUser]?, fault : Fault?) -> Void)?) {
let backendless = Backendless.sharedInstance()
let query = BackendlessDataQuery()
// Use backendless.persistenceService to obtain a ref to a data store for the class
let whereClause = "name LIKE '\(name)'"
query.whereClause = whereClause
let dataStore = backendless.persistenceService.of(BackendlessUser.ofClass()) as IDataStore
dataStore.find(query, response: { (retrievedCollection) -> Void in
print("Successfully retrieved collection")
completed!(users: retrievedCollection.data as? [BackendlessUser], fault: nil)
}) { (fault) -> Void in
print("Server reported an error: \(fault)")
completed!(users: nil, fault: fault)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment