Struggling to retrieve object by id with relations (flutter)

Hello!

I want to get one specific Exhibit from the database by searching the relevant table for its id which I pass in. I also want to get all it’s relation information as well, but am struggling to do this from the docs.

Screenshot 2023-03-22 at 22.40.43

When I hover over findById it tells me I can have a queryBuilder as optional, but I am struggling to pass it in correctly. The following is my code as it stands:

static fetchExhibitWithRelationsById(String id) {
    var query = DataQueryBuilder()
      ..related = ['linkedVenue', 'linkedCategories']
      ..whereClause = 'objectId=\'$id\'';

    var dbdata = Backendless.data
        .withClass<Exhibit>()
        .findById(id, query) // errors here!
        .then((exhibits) {
      return exhibits;
    });
    return dbdata;
  }

The error says: “Too many positional arguments: 1 expected, but 2 found”. Any help would be much appreciated, as always :slight_smile:

Hello, @Ilayda_B.

I think you need to read or watch some guides for flutter devs. You just sent wrong parameters in method.
In your screenshot you can see that id requirement parameter, others - not required. In this case these should be passed in method like this:
(id, queryBuilder: query);
Additionally, id you use findById method you don’t need to add whereClause with id of object.

Regards, Nikita.

Thank you for your quick response, that’s worked now!