0
@Operation.get()
  Future<Response> getAllCoworking({@Bind.query('l') String location}) async {
    final query = Query<Coworking>(context);
    /*if (location != null) {
      query.where((x) => x.title).contains(
            location,
            caseSensitive: false,
          );
    }*/
    query
      ..sortBy((w) => w.title, QuerySortOrder.ascending)
      ..fetchLimit = 5;
    final coworkingList = await query.fetch();
    return Response.ok(coworkingList);
  }

JSON Object

[
    {
        "id": 1,
        "title": "House of Words",
        "content": {
            "location": "Jaipur"
        }
    },
    {
        "id": 2,
        "title": "T-START UDAIPUR",
        "content": {
            "location": "Udaipur"
        }
    },
    {
        "id": 3,
        "title": "Thalagiri Co-Working Space",
        "content": {
            "location": "Udaipur"
        }
    }
]

i want to do http request http://localhost:8888?l=jaipur

how can i create a aqueduct query to fetch row where jsonb column has value for example

i just want to fetch where location is jaipur

1 Answers1

0

query.predicate = QueryPredicate("content ->> 'location' = @loc", {"loc" : location});