As of April 12th, you must go to Progress SupportLink to create new support cases or to access existing cases. Please, bookmark the SupportLink URL and use the new portal to contact the support team.
Reading through the querying section and I come across the special keys that I can use to query some data. I'm having trouble getting a working version to query the dates, I know it's mentioned that it is possible to do so with these special keys but I can't find a good example of someone using it.
Best Answer
P
Pranav J
said
over 5 years ago
Shae,
Following is the working example of using special key for sorting the queried result:
let predicate = NSPredicate(format: "_acl.creator == %@", "5894327d7259704a34axxx7b") let sortDescriptor = NSSortDescriptor(key: Entity.Key.entityId, ascending: true) let query = Query(predicate: predicate, sortDescriptors: [sortDescriptor])
dataStore.find(query) { (result: Result<AnyRandomAccessCollection<Book>, Swift.Error>) in switch result { case .success(let books): print("Books fetched are: \(books)") print("Books count is: \(books.count)") case .failure(let error): print("Error: \(error)") } }
Please do let me know your usecase for querying. What you are trying to achieve? It will help me better understand your usecase.
Shae Hazelwood
Reading through the querying section and I come across the special keys that I can use to query some data. I'm having trouble getting a working version to query the dates, I know it's mentioned that it is possible to do so with these special keys but I can't find a good example of someone using it.
Shae,
Following is the working example of using special key for sorting the queried result:
let predicate = NSPredicate(format: "_acl.creator == %@", "5894327d7259704a34axxx7b")
let sortDescriptor = NSSortDescriptor(key: Entity.Key.entityId, ascending: true)
let query = Query(predicate: predicate, sortDescriptors: [sortDescriptor])
dataStore.find(query) { (result: Result<AnyRandomAccessCollection<Book>, Swift.Error>) in
switch result {
case .success(let books):
print("Books fetched are: \(books)")
print("Books count is: \(books.count)")
case .failure(let error):
print("Error: \(error)")
}
}
Please do let me know your usecase for querying. What you are trying to achieve? It will help me better understand your usecase.
Thanks,
Pranav
- Oldest First
- Popular
- Newest First
Sorted by Oldest FirstPranav J
Shae,
Following is the working example of using special key for sorting the queried result:
let predicate = NSPredicate(format: "_acl.creator == %@", "5894327d7259704a34axxx7b")
let sortDescriptor = NSSortDescriptor(key: Entity.Key.entityId, ascending: true)
let query = Query(predicate: predicate, sortDescriptors: [sortDescriptor])
dataStore.find(query) { (result: Result<AnyRandomAccessCollection<Book>, Swift.Error>) in
switch result {
case .success(let books):
print("Books fetched are: \(books)")
print("Books count is: \(books.count)")
case .failure(let error):
print("Error: \(error)")
}
}
Please do let me know your usecase for querying. What you are trying to achieve? It will help me better understand your usecase.
Thanks,
Pranav
Shae Hazelwood
Pranav,
I'm sorting items by date so I can display the newest item first
george cox
I should do my engineering homework and it includes using this key to sort items in my query. Thank you very much for your help!
-
Why do I get "Undefined symbols" errors when building with KinveyKit?
-
How do I register push tokens?
-
When using social login, to perform a log-out, do I need to log out of the social network, Kinvey, o
-
How can I assign additional properties to users?
-
Does KinveyKit support 64-bit ARM devices, such as iPhone 5s?
-
Authorization Token Invalid or Expired
-
BOOL and how it is stored in the database.
-
Offline saving throwing errors
-
Custom endpoint not able to form request object
-
Security through business logic
See all 437 topics