小编Jak*_*son的帖子

Firestore 为 noSQL 和 Flutter 复制 SQL Join

我意识到与 NoSql 文档数据库(例如 FireStore)复制连接存在很多问题,但是我无法找到使用 Dart/Flutter 和 FireStore 的彻底解决方案。

我做了一些研究,我觉得在下面的示例中,我将寻找“多对多”关系(如果这是错误的,请纠正我),因为将来可能需要查看所有配置文件以及所有连接。

在 firebase 中,我有两个根级别集合(配置文件和连接):

profile
    > documentKey(Auto Generated)
         > name = "John Smith"
         > uid = "xyc4567"

    > documentKey(Auto Generated)
         > name = "Jane Doe"
         > uid = "abc1234"

    > documentKey(Auto Generated)
         > name = "Kate Dee"
         > uid = "efg8910"



connection
    > documentKey(Auto Generated)
         > type = "friend"
         > profileuid = "abc1234"
         > uid = "xyc4567"

    > documentKey(Auto Generated)
         > type = "family"
         > profileuid = "abc1234"
         > uid = "efg8910" …
Run Code Online (Sandbox Code Playgroud)

nosql dart firebase flutter google-cloud-firestore

5
推荐指数
1
解决办法
5532
查看次数

在 Supabase 数据库 (postgres) 中的单个查询中更新多行

我希望通过 Supabase 中的单个查询更新多行。我正在努力寻找如何在线完成此操作的示例。

对于此示例,以下是数据如何存在于数据库的“food”表中:

ID 标题 数量
1 苹果 10
2 香蕉 8
3 芒果 4

我想做的是更新单个查询中的 3 个数量字段(此代码不起作用,但应该让您了解我所追求的内容)。

const { data: item_data, error: item_error } = await supabase
   .from('food')
   .update({ qty: 11, }).eq('id', '1')
   .update({ qty: 9, }).eq('id', '2')
   .update({ qty: 6, }).eq('id', '3')
Run Code Online (Sandbox Code Playgroud)

postgresql supabase supabase-database

3
推荐指数
1
解决办法
4086
查看次数

Flutter - 将未来列表传递给 SearchDelegate

我一直在关注无聊的 flutter show上的 Flutter Search 教程 。我一直在尝试使用从未来列表派生的列表来实现相同的功能,其中数据来自 api(在本例中为 Aqueduct 服务器)。

目前,我的屏幕列出了 api 中的所有联系人,我现在想针对该联系人列表进行搜索。我假设将相同的列表(已经显示)传递给搜索委托是最佳实践。不幸的是,我不确定如何实现这一目标。

我的代码如下(请注意,我已经删除了此示例的一些代码):

class _ContactsScreenState extends State<ContactsScreen> {
  static const _usersUrl = //url info;
  static final _token = //token info;
  static final _headers = {
    "Content-type" : "application/json", 
    "Accept": "application/json",
    "Authorization": "Bearer $_token",
  };

  HttpRequestStatus httpRequestStatus = HttpRequestStatus.NOT_DONE;

  Future<List<Contact>> readContacts() async {
    final response = await http.get(_usersUrl, headers: _headers);
    List responseJson = json.decode(response.body.toString());
    List<Contact> contactList = createContactList(responseJson);
    return contactList;
  }

  List<Contact> createContactList(List data) {
    List<Contact> list = …
Run Code Online (Sandbox Code Playgroud)

dart flutter aqueduct

2
推荐指数
1
解决办法
5119
查看次数