Flutter 我可以使用flatter在firestore上创建索引吗?
我使用下面的flatter代码查询firestore,firestore使用字段时间戳订购数据Flutter 我可以使用flatter在firestore上创建索引吗?,flutter,google-cloud-firestore,Flutter,Google Cloud Firestore,我使用下面的flatter代码查询firestore,firestore使用字段时间戳订购数据 var results = Firestore.instance.collection('post').orderBy('timestamp').getDocuments().then((value) { var list = value.documents; return list.map((doc) { return doc.documentID; }).toList(); }
var results = Firestore.instance.collection('post').orderBy('timestamp').getDocuments().then((value) {
var list = value.documents;
return list.map((doc) {
return doc.documentID;
}).toList();
});
当我运行此代码时,它抛出以下异常,表示需要索引:
W/Firestore(31110):(21.3.0)[Firestore]:侦听查询(app/jqh7fp9xczwyiqre7le/post,其中readAccess数组包含任何[wzkimodx6wyvqdsw3az3xrunm2,PUBLIC]order by-timestamp,name)失败:状态{code=failed\u前提条件,描述=查询需要索引。您可以在此处创建它:
例外情况甚至还包括一个漂亮的链接。打开该链接时,会弹出一个漂亮的UI,使我能够创建索引,只需简单的单击:
问题:尽管上面看起来很简单,但我对此不太满意。我更希望能够从代码中创建索引。在代码中,我正在寻找类似以下内容的内容:
Firestore.instance.collection('post').API-TO-CREATE-INDEX('timestamp');
是否存在?请提供建议。非常感谢。无法从客户端应用创建索引。您有三个主要选择:
另请参见。无法从客户端应用创建索引。您有三个主要选择: