Firestore中的TTL策略,用于数值数据类型而不是时间戳/日期时间数据类型。

huangapple go评论56阅读模式
英文:

TTL Policy in Firestore for a Numeric data type instead of Timestamp/DateTime data type

问题

我有一个Firestore集合,我将时间戳存储为数字数据类型,而不是时间戳数据类型。是否有办法可以针对该字段在该集合上创建TTL策略?
因为我的应用程序已经投入生产,所以现在无法将数据类型更改为时间戳。
尽管我之前没有将字段设置为时间戳是我的疏忽,但我无法找到使用数字数据类型实现这一目标的方法。

英文:

I have a Firestore collection where I am storing Timestamp as a numeric data type instead of timestamp data type. Is there any way I can create a TTL Policy on that collection for this field?
I cannot change the data type to Timestamp now because my app is already in production.

Granted, this was a miss from my side for not making the field as Timestamp but I cannot find any way to do this with a numeric data type.

答案1

得分: 0

你要求的功能(根据数字时间戳而非日期/时间戳值删除过时文档)不存在。您可以提交功能请求,但更快的做法可能是更改代码以将值存储为适当的类型,并将现有文档更新以匹配该类型,或者使用您自己的应用程序代码清理这些文档。

英文:

The feature you're asking for (to delete outdated documents based on a numerical timestamp since the epoch, rather than a date/timestamp value) does not exist.

You could file a feature request for it, but it's probably faster to change your code to store the value in the proper type going forward and either update the existing documents to match that type, or to clean those up with your own application code.

huangapple
  • 本文由 发表于 2023年6月12日 14:58:19
  • 转载请务必保留本文链接:https://go.coder-hub.com/76454241.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定