如何在颤抖中使用orderby [英] how to use where with orderby in flutter

查看:51
本文介绍了如何在颤抖中使用orderby的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何在flutter中与orderBy一起使用.

how to use where with orderBy in flutter.

任何人都可以告诉我这些索引的工作方式以及如何正确创建它们.

any one can tell me how these indexes are working and how to properly create them.

Query query = Firestore.instance
        .collection('clients')
        .where('sequenceStatus', isEqualTo: sequenceName)
        .orderBy('created', descending: true)
        .limit(20);

W/Firestore(19854):(19.0.0)[Firestore]:侦听查询(sequenceStatus ==引用-created创建的客户端,- name 的客户端)失败:状态{code =FAILED_PRECONDITION,描述=查询需要索引.你可以在这里创建它: https://开头的控制台.firebase.google.com/project/rigatoinfissitest/database/firestore/indexes?create_composite=ClFwcm9qZWN0cy9yaWdhdG9pbmZpc3NpdGVzdC9kYXRhYmFzZXMvKGRlZmF1bHQpL2NvbGxlY3Rpb25Hcm91cHMvY2xpZW50cy9pbmRleGVzL18QARoSCg5zZXF1ZW5jZVN0YXR1cxABGgsKB2NyZWF0ZWQQAhoMCghfX25hbWVfXxAC 的,原因= NULL}

W/Firestore(19854): (19.0.0) [Firestore]: Listen for Query(clients where sequenceStatus == quotes order by -created, -name) failed: Status{code=FAILED_PRECONDITION, description=The query requires an index. You can create it here: https://console.firebase.google.com/project/rigatoinfissitest/database/firestore/indexes?create_composite=ClFwcm9qZWN0cy9yaWdhdG9pbmZpc3NpdGVzdC9kYXRhYmFzZXMvKGRlZmF1bHQpL2NvbGxlY3Rpb25Hcm91cHMvY2xpZW50cy9pbmRleGVzL18QARoSCg5zZXF1ZW5jZVN0YXR1cxABGgsKB2NyZWF0ZWQQAhoMCghfX25hbWVfXxAC, cause=null}

推荐答案

重定向到您在问题中发布的上述链接后,请遵循以下5个步骤或从第3步开始.

Follow below 5 steps or start from 3rd step after redirecting on above link you have posted in the question.

  1. 转到您的Firebase控制台数据库

  1. Go to your firebase console database

从那里选择索引.单击添加索引.

Select Indexes from there. Click on Add index.

在集合ID"字段中输入 clients (集合名称).

Enter clients (collection name) in Collection ID field.

在第一个字段中添加 sequenceStatus (where子句字段),并保持升序.

Add sequenceStatus (where clause field) in 1st field and leave Ascending as it is.

添加创建的(orderby字段)第二个字段,并保持升序.

Add created (orderby field) 2nd field and leave Ascending as it is.

单击创建索引".

现在,运行查询.它将正常工作.

Now, run your query. It will work just fine.

干杯!

这篇关于如何在颤抖中使用orderby的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆