英文:
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.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论