How can we get a server timestamp, without using the realtime database
but using instead 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
})
}
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…