云功能中的云Firestore

Luc*_*ski 6 node.js firebase google-cloud-functions google-cloud-firestore

我想将新的Cloud Firestore集成到我的云功能中.

我更新了node.js并在我的mac上安装了最新的firebase版本.

文件说:

exports.myFunctionName = functions.firestore
  .document('users/marie').onWrite((event) => {
    // ... Your code here
 });
Run Code Online (Sandbox Code Playgroud)

应该管用.我只是复制代码并将其粘贴到index.js中,就像其他所有实时数据库函数一样.当我部署功能代码($ firebase deploy --only functions)时,我收到此错误:

Cannot read property 'document' of undefined
    at Object.<anonymous> (/private/var/folders/zm/wp2415l929s472jv7kzbt3km0000gn/T/fbfn_21520Y4xqAJosBNHe/index.js:196:45)
    at Module._compile (module.js:570:32)
    at Object.Module._extensions..js (module.js:579:10)
    at Module.load (module.js:487:32)
    at tryModuleLoad (module.js:446:12)
Run Code Online (Sandbox Code Playgroud)

关于这个问题的任何建议/想法?

Luc*_*ski 0

好吧,我尝试了所有这些方法,但没有成功。但 firebase 推出了更新,现在可以使用了:)

看起来他们有一些错误。

感谢您的帮助!