首页 文章

获取最新更新信息/ Firebase

提问于
浏览
0

Firebase 上使用数据库时,是否可以在iOS应用程序中使用某些标准API检查文档上次更新的日期(和时间)?我的意思是没有实现我自己的系统,以了解它最后一次触摸 .

如果有一个字段"lastUpdate"时间戳,那将会很方便 .

1 回答

  • 1

    Firebase实时数据库和Cloud Firestore都不会自动为写入数据添加时间戳字段 .

    如果您想要这样的字段,则必须自己添加,可以是客户端,也可以是Cloud Functions .

    有关后者的简单示例(跟踪数据库中上次修改的节点的时间),请参阅this folder in the functions-samples repo . 主要代码:

    exports.touch = functions.database.ref('/chat/{message}').onWrite(
        (change, context) => admin.database().ref('/lastmodified').set(context.timestamp));
    

相关问题