I've the parse database name as Timetable, I want to get the data from the column "Intake", but I've a lot of data in it, around 5000 records. I know the maximum query objects that we can get is 1000, but how to get more than 1000 records? The codes that I wrote is only query for 1000
var query = PFQuery(className: "Timetable")
var limit:NSInteger = 1000
var skip:NSInteger = 0
query.limit = limit
query.skip = skip
query.orderByAscending("Intake")
query.findObjectsInBackgroundWithBlock
{
(objects:[AnyObject]?, error:NSError?) -> Void in
if error == nil
{
query.findObjectsInBackgroundWithBlock
{
(objects:[AnyObject]?, error:NSError?) -> Void in
if error == nil
{
for object in objects! as [AnyObject]
{
var intakeCode = object["Intake"] as? String
if !self.pickerString.containsObject(object["Intake"] as! String) {
self.pickerString.addObject(object["Intake"] as! String)
}
}
self.pvIntakeCode.reloadAllComponents()
}
else
{
NSLog("Error: %@ %@", error!, error!.userInfo!)
}
}
}
else
{
NSLog("Error: %@ %@", error!, error!.userInfo!)
}
I know this problem is existing from stackoverflow, but I really don't understand what it says. (Another question is from here:Parse.com query for 10000 (10K) objects). But I don't understand about it, sorry for asking the question again.
The limit of 1000 records is there for a reason. You should never need to retrieve that many objects in one query, as this will most likely clog down your app and yield sluggish performance.
I can see two scenarios why you want to retrieve all records:
In scenario 1, what you really want is to page through the results. Since you can only show a few records on the screen at once, you should rather query for i.e. 100 records, and then trigger a new query for the next 100 records as the user is scrolling and nearing the end of the first 100 etc, until the user has scrolled through them all (which would be a very patient user...). You solve this by querying with a limit and a skip:
query.setLimit(100)
query.setSkip(skip)
First run, skip is 0. For every consecutive run, you increase skip with 100.
In scenario 2, you don't want to do this on the client. Enter background jobs! https://parse.com/docs/js/guide#cloud-code-advanced-background-jobs
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With