admin管理员组文章数量:1435859
Trying out Firestore REST API, the documentation states that to order items ?orderBy=name%20desc
this orders using the document name in descending order. The documents I need to order have the following structure
{
"name": "document_name",
"fields":{
"createTime": "2024-08-23T23:06:05.206209Z",
}
}
How could I order using the createTime
field? since doing ?orderBy=fields.createTime
returns empty JSON.
Trying out Firestore REST API, the documentation states that to order items ?orderBy=name%20desc
this orders using the document name in descending order. The documents I need to order have the following structure
{
"name": "document_name",
"fields":{
"createTime": "2024-08-23T23:06:05.206209Z",
}
}
How could I order using the createTime
field? since doing ?orderBy=fields.createTime
returns empty JSON.
1 Answer
Reset to default 0As far as I know, Firestore REST API doesn't allow ordering directly on nested fields (like fields.createTime
) as you are trying to do right now. However, this technique will only work if you use mobile or web SDKs.
So to solve this, I recommend you modify the structure of your document so that createTime
becomes a top-level field in the document and not a nested one:
{
"name": "document_name",
"createTime": "2024-08-23T23:06:05.206209Z", //
本文标签:
firebaseOrdering Firestore documents using a nested fieldStack Overflow
版权声明:本文标题:firebase - Ordering Firestore documents using a nested field - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人,
转载请联系作者并注明出处:http://www.betaflare.com/web/1745636710a2667603.html,
本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
google-cloud-firestore
tag since using?orderBy=
in the query string is the way used to filter with the RTDB REST API – Renaud Tarnec Commented Nov 18, 2024 at 8:06