🚀
シンServerpodを解読する 〜find
一番簡単な「全選択またはキーワードで絞り込み」
まず1.1で動いてたCode。
Future<List<Places>> getPlaces(Session session, {String? keyword}) async {
return await Places.find(
session,
where: (t) =>
keyword != null ? t.country.equals(keyword) : Constant(true),
orderBy: Places.t.place
);
}
1.2に対応。
Future<List<Places>> getPlaces(Session session, {String? keyword}) async {
return await Places.db.find(
session,
where: (t) =>
keyword != null ? t.country.equals(keyword) : Constant.bool(true),
orderBy: (places) => places.place,
);
}
documentでは、orderByの書き方、変更なしなのだが、どうしてもエラーが消えないので、
Mediumの記事に合わせてみたら、動いた。
なんでかわからない。
次はもうちょっと複雑な絞り込み
Flutter大学はFlutterエンジニアに特化した学習コミュニティです! 初心者から中上級者まで幅広く在籍し、切磋琢磨しています! 入会をご希望の方はこちらから→ flutteruniv.com
Discussion