Retrieving last object from a table with a 1:many relation with the user table

My users table has a one to many relations with table “B”.

How to get the last object in table “B” for the logged in user?

I can’t seem to find how to use “findLast” directly on the related table “B”.


public void Backendless.Persistence.of("B").findLast(Asyncallback<Map> responder)

give me the desired result for the logged in user? It’s not.

When should you use


instead of


when doing object retrieval?

You could do a search with whereClause. When you say find last “for the logged in user”, could you elaborate what you mean by that? For example, is it the last updated object by the current user? or is it the last created object? or what exactly?

The last created object in the related table, i have a data form that has texts and images, i don’t want the images to go into my file system before the text entries are captured in the related table for obvious reasons, so the created entry has to wait for the File System to return the image urls, which i then want to add to that particular entry.

I’d use the following query:

Users[relationNameToB].objectId = ‘objectId-of-the-current-user’

Make sure to:

    set the pageSize to 1 set the sortBy to "created DESC
With pageSize set to 1 the result will be a collection of 1 object, that's the last one created by the specified user.


Thanks Mark, but is that for Android? I never came across the above queries. If yes, could provide a link to the relevant documentation so i can pore through to implement your idea?


It is universal, all SDKs provide support for this. Here’s the doc for 4.0:

Search with where clause:



Very helpful, just one thing

I have done this so far

String whereClause = "Users[relationNameToB]" +
 ".objectId='" + user.getObjectId() + "'";

DataQueryBuilder queryBuilder = DataQueryBuilder.create();
queryBuilder.setSortBy("created DESC");

Do i now make the query as

Backendless.Data.of(BackendlessUser.class).find(queryBuilder, new AsyncCallback<List<BackendlessUser>>(){

Which looks like it will give me a list of users…


Backendless.Data.of(B.class).find(queryBuilder, new AsyncCallback<List<B>>(){

to give me the last created object in the related table…

You need to send the query to the table where you want to retrieve the data from. In this case, it is table “B”

Thank you, appreciated.