升级到 8.0.0 后,出现以下错误:
尝试导入错误:“initializeApp”未从“firebase/app”导出(导入为“firebase”)。
我的导入看起来像这样:
import * as firebase from "firebase/app"
firebase.initializeApp({ ... })
Run Code Online (Sandbox Code Playgroud)
TypeScript 也抱怨:
类型“typeof import("/path/to/my/file")”上不存在属性“initializeApp”。ts(2339)
我该如何解决?
如何在不使用实时数据库但使用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