gpt4 book ai didi

node.js - 在Cloud Functions for Firebase中从Firestore触发器获取用户ID?

转载 作者:行者123 更新时间:2023-12-04 01:31:41 25 4
gpt4 key购买 nike

在下面的示例中,是否可以获取写入“offers/{offerId}”的用户的用户ID(uid)?我尝试按照here的说明进行操作,但在Firestore中不起作用。

exports.onNewOffer = functions.firestore
.document('offers/{offerId}')
.onCreate(event => {
...
});

最佳答案

我为此苦苦挣扎了一段时间,最后联系了Firebase支持部门:
I was trying to achieve this.
Firestore数据库触发器的事件对象中未定义event.auth.uid。 (它适用于实时数据库触发器)
当我console.log(event)时,我在输出中找不到任何auth
官方支持答案:

Sorry the auth is not yet added in the Firestore SDK. We have it listed in the next features.

Keep an eye out on our release notes for any further updates.


我希望这可以节省一些时间。
更新:
该问题已解决,该功能将永远无法实现:

Hi there again everyone - another update. It has been decided that unfortunately native support for context.auth for Firestore triggers will not be implemented due to technical constraints. However, there is a different solution in the works that hopefully will satisfy your use case, but I cannot share details. On this forum we generally keep open only issues that can be solved inside the functions SDK itself - I've kept this one open since it seemed important and I wanted to provide some updates on the internal bugs tracking this work. Now that a decision has been reached, I'm going to close this out. Thanks again for everyone's patience and I'm sorry I don't have better news. Please use the workaround referenced in here.

关于node.js - 在Cloud Functions for Firebase中从Firestore触发器获取用户ID?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46912161/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com