【问题标题】:Aqueduct framework fetch Query where by documentAqueduct 框架 fetch 查询 where by document
【发布时间】:2020-02-17 17:59:13
【问题描述】:
@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 列具有值的行,例如

我只想获取斋浦尔的位置

【问题讨论】:

    标签: dart aqueduct


    【解决方案1】:

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

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2021-12-31
      • 1970-01-01
      • 2011-06-29
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-04-05
      • 1970-01-01
      相关资源
      最近更新 更多