Support Topics Documentation Slack YouTube Blog

Nested query

is it possible to do nested where clauses?

I have an array of objects I saved locally. I want to retrieve ones I don’t have and ones that I have but have been updated.
Is this possible in a single query?

Thanks
Robert

Hello @robert-j

Please describe in more detail what you want to do.

I don’t know if I understood you correctly, but perhaps the following documentation will help:
https://backendless.com/docs/ios/data_search_with_where_clause.html
https://backendless.com/docs/ios/data_search_with_dates.html

Sorry
how do I query only new objects or updated objects

"objectId != obj.objectId OR (objectId == obj.objectId AND updated > obj.updated)"

is something like this possible?

Hi Robert,

The concept of “new” objects would be relative to the point in time when you checked for it last time. Say you check every morning at 8am. When you check on Tuesday, the “new” objects would be the ones created since 8am on Monday. Pretty much the same goes for the updated objects.

If I understood what you want to do correctly, this will be a matter of querying against the created and the updated columns using the date-based comparison in where clause.

Regards,
Mark

that’s a interesting take, let me do some testing. Thanks!

I’m having trouble with this. Im able to pull all new objects, but im not able to pass a 3rd requirement. I need only new objects that belong to me.

here is the where clause im using

"updated > \'01.01.1980 05:00:00 GMT\' OR created > \'01.01.1980 05:00:00 GMT\' IN (BESubmittedForms.be_uniqueCompanyID = \'HQ-62-SCF\')"

I tried removing the IN part of the clause and setting the having to

queryBuilder.setProperties(properties: ["be_uniqueCompanyID as ID"])
queryBuilder.setHavingClause(havingClause: "ID = '\(myCompanyDetails.be_uniqueCompanyID)'")

but that always returns zero objects

I’m really trying to avoid pulling several thousand objects each time I look for an update.

The having clause applies only when use aggregate functions.

The IN part requires enumerated values in the parenthesis that follow, for example:

IN ( 'value1', 'value2' )

would the following make sense in the context of what you’re trying to do?

(updated > \'01.01.1980 05:00:00 GMT\' OR created > \'01.01.1980 05:00:00 GMT\') AND (BESubmittedForms.be_uniqueCompanyID = \'HQ-62-SCF\')

Perfect, thanks