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 对象

[
    {
        "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"
        }
    }
]

我想做 http 请求http://localhost:8888?l=jaipur

例如,我如何创建渡槽查询以获取 jsonb 列具有值的行

我只想获取斋浦尔的位置

4

1 回答 1

0

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

于 2020-02-17T09:59:13.840 回答