【发布时间】:2020-09-01 17:46:28
【问题描述】:
这是我运行查询后遇到的错误
Error: FirebaseError: The query requires an index. You can create it here:
https://console.firebase.google.com/v1/r/project/jssr-6e16c/firestore/indexes?create_compo
site=Ckhwcm9qZWN0cy9qc3NyLTZlMTZjL2RhdGFiYXNlcy8oZGVmYXVsdCkvY29sbGVjdGlvbkdyb3Vwcy9BZG1pb
i9pbmRleGVzL18QARoLCgdwaG9uZU5vEAEaDQoJcGFydHlOYW1lEAIaDAoIX19uYW1lX18QAg
(failed-precondition)
at Object.throw_ [as throw] (http://localhost:58377/dart_sdk.js:4776:11)
at handleThenable
(http://localhost:58377/packages/firebase/src/storage.dart.lib.js:3237:21)
at handleThenable.throw (<anonymous>)
at onError (http://localhost:58377/dart_sdk.js:35663:38)
at _RootZone.runBinary (http://localhost:58377/dart_sdk.js:35547:58)
at _FutureListener.thenAwait.handleError (http://localhost:58377/dart_sdk.js:30969:50)
at handleError (http://localhost:58377/dart_sdk.js:31482:51)
at Function._propagateToListeners (http://localhost:58377/dart_sdk.js:31505:17)
at _Future.new.[_completeError] (http://localhost:58377/dart_sdk.js:31366:23)
at async._AsyncCallbackEntry.new.callback
(http://localhost:58377/dart_sdk.js:31401:31)
at Object._microtaskLoop (http://localhost:58377/dart_sdk.js:35759:13)
at _startMicrotaskLoop (http://localhost:58377/dart_sdk.js:35765:13)
at http://localhost:58377/dart_sdk.js:31707:9Application finished.
查询生成错误如下。 在此 phoneNo 和 lrNo 都是 document 中的字段,但它们是 String 但只包含数值(在客户端使用正则表达式验证)。
var temp = await fireStore
.collection("Admin")
.where("phoneNo", isEqualTo: TextFieldData.phoneNo)
.orderBy("lrNo", descending: false)
.getDocuments()
.then((value) => value);
return temp;
【问题讨论】:
标签: firebase flutter dart google-cloud-firestore