Hi there,
Hoping this is a simple question, but was unable to see it in the docs.
How can add a query whereClause where it returns unique objects of a column type?
Ie. I want to get all activity objects from my activityTable ordered from createdDate desc, and where the user object is unique. (so all recently created objects in table by each user)
Im in working in Swift, if you’re hoping to provide a code example.
Thanks!
Simon,
There is no way to do it with a single query. We plan to add support for so called “aggregation functions” which will let you do what you’re asking. Until then, you would need to perform data filtering either in custom server code or on the client.
Mark
Any progress on this ?
Hey Tomas,
Not yet, unfortunately; we’re currently concentrated on releasing version 4 from beta. But I can say that the aggregation functions are in the top priority list after that.
Any suggestions how than perform query of:
FROM (backendlesUSER) - TO (backendlessUser) - Message (String)
I want so select last message (by created), where from == “objectID” or to == “objectID” and from that list I want to filter unique rows with respect to to/from: ie to perform
Display last conversation between two users in list something like:
Something like groupBY…
Because currently I am taking all messages, performing query → display only those which are coming from or to me.
And then sort them by Created.
And then store first, with related user → var users = , users.push (userID)
and then ignore those messages with that user and continue…
But if this table will contain thousands of messages it will be massive overload
The only thing you cannot do right now is filtering the unique messages, all the other requirements are accomplishable with one query:
DataQueryBuilder queryBuilder = DataQueryBuilder.create();
queryBuilder.setWhereClause( "from = 'objectIdFrom' AND to = 'objectIdTo'" );
queryBuilder.setSortBy( "created DESC" );
Backendless.Data.of( Message.class ).find( queryBuilder, new AsyncCallback() {...} );