Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/opencv/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Firebase Firestore云函数,添加作者';创建文档的UID_Firebase_Google Cloud Firestore_Google Cloud Functions - Fatal编程技术网

Firebase Firestore云函数,添加作者';创建文档的UID

Firebase Firestore云函数,添加作者';创建文档的UID,firebase,google-cloud-firestore,google-cloud-functions,Firebase,Google Cloud Firestore,Google Cloud Functions,当我的一个用户创建一个特定的文档时,例如一篇文章,我想将它的UID添加到文档中 我试图找到一种通过云函数和onCreate触发器实现这一点的方法,但似乎在这些函数中无法访问用户的UID exports.createPublication = functions.firestore .document('publications/{publication}') .onCreate((snap, context) => { const newValue = sna

当我的一个用户创建一个特定的文档时,例如一篇文章,我想将它的UID添加到文档中

我试图找到一种通过云函数和onCreate触发器实现这一点的方法,但似乎在这些函数中无法访问用户的UID

exports.createPublication = functions.firestore
    .document('publications/{publication}')
    .onCreate((snap, context) => {

      const newValue = snap.data();

      return snapshot.ref.child('authorId').set("ID");

    });
我真的很惊讶Firestore没有像其他数据库那样在本机添加AuthorId字段(Mongo、Parse等)
当然,我可以从客户端添加此UID,但我认为它有点脏。

Firestore触发器当前无法知道调用触发器的已验证用户的UID。这是一个正在研究的特性


如果文档ID恰好是用户的uid,则可以使用安全规则限制该用户的写入权限,然后使用通配符了解uid,但这听起来像是不能在这里使用的把戏。

如果您能在firestore触发的云函数功能中添加获取身份验证信息,我将不胜感激。@dshukertjr如果您有功能请求,请在此处存档: