Returning wrong number of objects?

Hi. I’m doing a regular query where when a user likes a post, the number of people who have liked it show up. For some reason, the user is showing up twice instead of once even though a query is set in place to return just that user.

- (void)getPeople
{
    QueryOptions *query = [QueryOptions query];
    BackendlessDataQuery *dataQuery = [BackendlessDataQuery query:nil where:nil query:query];
    dataQuery.whereClause = [NSString stringWithFormat:@"person = \'%@\'", currentUser.objectId];
    dataQuery.whereClause = [NSString stringWithFormat:@"eventday = \'%@\'", day];
    
    [backendless.persistenceService find:[Rsvp class]
                               dataQuery:[BackendlessDataQuery query]
                                response:^(BackendlessCollection *collection){
                                    [[UIApplication sharedApplication] setNetworkActivityIndicatorVisible:NO];
                                    [_dataRSVP addObjectsFromArray:[(BackendlessCollection *)collection data]];
                                    [_collectionView reloadData];
                                  
                                }
                                   error:^(Fault *fault) {
                                   }];


    
    
    
}

This is the code. Could something be wrong? Can there be two whereclauses? Thanks

Please investigate this doc, in particular, “Loading a Subset of Related Child Objects” section.

Hi. You’re always so helpful. Thank you. What am I to look at exactly? :slight_smile: I have the RSVP seperate from the list of shows. You mean I could connect them with relations?

For some reason, this query is returning everything instead of returning results requested in the whereclause.









   BackendlessDataQuery *query = [BackendlessDataQuery query];

    query.whereClause = [NSString stringWithFormat:@"eventday = \'%@\' AND person = \'%@\'", day, currentUser.objectId];

    [backendless.persistenceService find:[Rsvp class] dataQuery:query response:^(BackendlessCollection *collection) {

        _dataRSVP = [NSArray arrayWithArray:collection.data];

        [self checkCount];

    } error:^(Fault *error) {

        NSLog(@"UsersViewController -> viewDidLoad: (FAULT) %@", error);

    }];

    

You can always test your whereClause query using Backendless Console:

https://backendless.com/feature-14-sql-based-search-for-data-objects-using-console/

Hi Mark,

When i use advanced query , every time i am getting 10 objects only as a result. Even though more than 10 objects are present in database.

In my scenario:
User have option to add device. I can see more than 10 devices under one user in backendless database. but while

BackendlessDataQuery query=new BackendlessDataQuery();
query.setWhereClause(String.format(“owner= ‘%s’”,user));

QueryOptions options=new QueryOptions();
options.addSortByOption(“name ASC”);
query.setQueryOptions(options);

Backendless.Persistence.of(Device.class).find(query, new AsyncCallback<BackendlessCollection<Device>>() {
@Override
public void handleResponse(BackendlessCollection<Device> response) {
List<Device> dList=response.getData();

    int size=dList.size();
    Log.d("No.of Devices:\t", ": " +size );
    if(size==0){
        Toast.makeText(getActivity(), "No Devices!!", Toast.LENGTH_SHORT).show();


    }else {
         adapter = new DeviceListAdapter(dList);
        AlphaInAnimationAdapter alphaAdapter = new AlphaInAnimationAdapter(adapter);
        alphaAdapter.setDuration(1000);
        recyclerView.setAdapter(alphaAdapter);

    }


    linlaHeaderProgress.setVisibility(View.GONE);
}

@Override
public void handleFault(BackendlessFault fault) {

}

});

every time it is returning 10 items only.

Please help,

Thanks

The objects are received in pages, and the default page size is 10.
You can either set the pageSize to a bigger value (but not bigger than 100), or use the BackendlessCollection’s nextPage() method to retrieve the next 10 objects.

Thanks Sergy Chupov

I will try it…