英文:
Firebase get with where clause and order of data returned
问题
在数据返回时,结果的顺序将与查询的顺序(["51", "32", "23", "41"])相同吗?是否有相关的文档参考?我想知道哪些数据匹配文档 ID 51,哪些数据匹配文档 ID 32等。
英文:
I have below code in my cloud function. Firestore api call is made to retrieve data that matches a certain document id.
await myClinics
.where(FieldPath.documentId(), "in", ["51","32","23","41"])
.get()
.then((snapshots) => {
snapshots.forEach((doc) => {
// console.log(doc.data());
});
});
When data is returned, what will be the order of results? will it be of same order as the query (["51","32","23","41"])?
Is there a documentation reference relating to this?
I would like to know which data matches document ID 51 and which data matches document ID 32 etc..
This is more of a question.
答案1
得分: 0
文档将按照它们在索引中出现的顺序返回,而不是按照您在in
子句中指定值的顺序返回。
如果您想要为文档51
执行特定的代码,请在您的代码中检查doc.id
的值。
英文:
The documents will be returned in the order in which they occur in the index, not in the order in which you specify the values in the in
clause.
If you want to execute specific code for document 51
, check the doc.id
value in your code.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论