gpt4 book ai didi

firebase.firestore.FieldValue.serverTimestamp() concat with string val(firebase.firestore.FieldValue.serverTimestamp()与字符串val连接)

转载 作者:bug小助手 更新时间:2023-10-22 17:34:56 36 4
gpt4 key购买 nike



As per Firebase documentation, we should not use incremental values as it may cause hotspots.
I have multiple subcollections and I am only interested in ordering my subcollection, so I want to concat server-side timestamp with a document ID (which represents the document inside which my subcollection exist)

根据Firebase文档,我们不应该使用增量值,因为它可能会导致热点。我有多个子集合,我只对子集合的排序感兴趣,所以我想将服务器端时间戳与文档ID(表示子集合所在的文档)连接起来


But as the serverside time stamp is calculated at the server level, how can I do it?

但是,由于服务器端时间戳是在服务器级别计算的,我该怎么做呢?


更多回答

You can't - if you must use a server timestamp, you can only write that value to a field by itself using the server timestamp token in your code.

不能——如果必须使用服务器时间戳,则只能使用代码中的服务器时间戳令牌将该值写入字段。

优秀答案推荐



I am having multiple subcollections and I am only interested in ordering my subcollections.



You cannot order subcollections. According to the docs, the ordering refers to documents and not to collections or subcollections.

不能订购子集合。根据文档,排序是指文档,而不是集合或子集合。



I want to concat server-side timestamp with a document ID.



You can choose to name the subcollections any way you want, but you won't find a function that will order them.

您可以选择以任何方式命名子集合,但找不到可以对其排序的函数。



But as the serverside timestamp is calculated at the server level, how can I do it?



As @DougStevenson mentioned in his comment, if you need to use a server timestamp, then you have to write that value to a field (of the document) using the server timestamp token in your application's code.

正如@DougStevenson在评论中提到的,如果你需要使用服务器时间戳,那么你必须使用应用程序代码中的服务器时间戳标记将该值写入(文档的)字段。


更多回答

Hey there. Did my answer help? Can I help you with other information?

嘿。我的回答有帮助吗?我能帮你提供其他信息吗?

36 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com