how to use where with orderby in flutter

依然范特西╮ 提交于 2021-02-19 05:41:30

问题


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]: 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}


回答1:


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

  1. Go to your firebase console database

  2. Select Indexes from there. Click on Add index.

  3. Enter clients (collection name) in Collection ID field.

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

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

  6. Click Create index.

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

Cheers!



来源:https://stackoverflow.com/questions/57372921/how-to-use-where-with-orderby-in-flutter

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!