Backendless Support
 
Answered

collection.data

Hi,

I wrote some code years ago where I used backendless as part of a proof of concept. I had to bring it back from the dead and fired up ye old backendless, turns out you guys have had some major changes. No biggy I have upgraded my account and installed the changes. But I'm having a little bit of an issue trying to work out how to reference the data the way I use to. Below is the new code, I'm particularly interested in how to rewrite collection.data portion.

New Query as per your documentation.

p.p1 {margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Menlo; color: #000000; background-color: #ffffff}

span.s1 {color: #ba2da2}

span.s2 {color: #703daa}

span.s3 {color: #78492a}

span.s4 {color: #3e1e81}

span.s5 {color: #d12f1b}

span.s6 {color: #4f8187}

span.s7 {text-decoration: underline ; color: #d12f1b}

span.s8 {text-decoration: underline}

span.s9 {text-decoration: underline ; color: #703daa}

id<IDataStore> queryAircraft = [backendless.data ofTable:@"Aircraft"];

DataQueryBuilder *queryBuilder = [DataQueryBuilder new];

NSString *whereClause = [NSString stringWithFormat:@"AircraftIdentification = \'%@\'", aircraftRegoValue];

[queryBuilder setWhereClause:whereClause];

[queryAircraft find:queryBuilder

response:^(NSArray *aircraftObjects) {

NSLog(@"Retrieved %i objects", (int)aircraftObjects.count);

aircraftCount = [NSString stringWithFormat:@"%d",aircraftObjects.count];

}

error:^(Fault *fault) {

NSLog(@"Server reported an error: %@", fault.message);

}];

p.p1 {margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Menlo; color: #4f8187; background-color: #ffffff}

p.p2 {margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Menlo; color: #008400; background-color: #ffffff}

p.p3 {margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Menlo; color: #000000; background-color: #ffffff}

span.s1 {color: #000000}

span.s2 {color: #ba2da2}

span.s3 {color: #272ad8}

span.s4 {color: #4f8187}

span.s5 {color: #703daa}

span.s6 {color: #3e1e81}

span.s7 {text-decoration: underline}

if (aircraftCount == 0) {

//reset the NSArray to be blank because no values came back

flightRecordData = [[NSMutableArray alloc]init];

}

else

{

flightRecordData = [[NSMutableArray alloc]init];

for (FlightLog *flightlog in collection.data) <---I loop over the results using the NSMutableArray....well I use to....

{

How should I be referencing the data returned instance? queryAircraft?

Please understand I haven't coded in about 3 years...so be gentle with your answers. I have many cob webs...

Cheers

Leave a Comment

Comments (4)

photo
1

Hello jeremy,

I assume you are using Backendless 4, right?

Please check this documentation for v4.

And here you can find the differences between data retrieval in v3 and v4.

Regards, Olga

photo
1

Hi Olga,

Thanks for the response. I have seen the documentation and have read through it a couple of times. Clearly I'm Missing something.

Using your example,

[contactStorage find:queryBuilder

response:^(NSArray *contactObjects) {

NSLog(@"Retrieved %i objects", (int)contactObjects.count);

}

contactObjects is the Array of which all the data is stored. Correct? So I'm thinking that I use this in my NSMutableArray. Then loop through the NSMutableArray for extracting elements that I wish to use.

Hope that makes sense.

Jeremy

photo
1

Hi Jeremy,

> contactObjects is the Array of which all the data is stored. Correct?

not all data from your table, but just a page, by default it is 10 records from your table. to get next 10 records you have to shift your offset with 10. Here it is a doc about paging https://backendless.com/docs/ios/doc.html#data_data_paging

photo
1

Hi Sergey,

Gotcha. Okay So really I need to paginate through items. Mmm...Okay,

Thanks everyone.

Jeremy