相关疑难解决方法(0)

如何使用Firestore获取Cloud Functions for Firebase中的服务器时间戳?

如何在不使用实时数据库但使用Firestore的情况下获取服务器时间戳?

import * as functions from 'firebase-functions'
import { Firestore } from '@google-cloud/firestore'

const db = new Firestore()

export let testIfMatch = functions.firestore
        .document('users/{userId}/invites/{invitedUid}')
        .onCreate(event => {
            let invite = <any>event.data.data()

            if (invite.accepted == true) {
              return db.collection('matches').add({
                friends: [userId, invitedUid],
                timestamp: doc.readTime // <--- not exactly the actual time
              })
            }
Run Code Online (Sandbox Code Playgroud)

javascript firebase google-cloud-functions google-cloud-firestore

14
推荐指数
2
解决办法
7142
查看次数