云功能部署会产生烦人的“路径”已弃用。警告没有燃料的迹象

发布于 2025-01-24 02:40:24 字数 664 浏览 0 评论 0原文

firebase cloud函数database.d.ts具有以下评论,该评论在我的IDE中和部署项目时发出警告:

/** @deprecated Removed in next major release to match Web SDK typings. */ 
path: string;

在许多云功能中,我创建词典,键是通往实时数据库节点的途径,只要我想更新条目。

这是我需要的确切行为,没有任何问题。但是,每次我部署云功能时,我都会受到50多个警告的欢迎:

path is deprecated: Removed in next major release to match Web SDK typings.

创建这些警告的终端调用是:

Running command: npm --prefix "$RESOURCE_DIR" run lint

如果没有路径变量,我必须创建一个自定义函数才能从databasereference创建路径和父键。这听起来很荒谬。这可能是一致问题吗?

文档中没有什么可说明他们正在删除路径变量的内容,我讨厌每次部署功能时都会看到此警告垃圾邮件。这是合法的警告吗?如果是这样,是否有一种替代方法可以从SDK内置的数据AbaseReference获取路径?

Firebase cloud functions database.d.ts has the following comment which throws warnings in my IDE and when I deploy my project:

/** @deprecated Removed in next major release to match Web SDK typings. */ 
path: string;

In many of my cloud functions, I create dictionaries with the keys being paths to realtime database nodes whenever I want to update entries.

This is the exact behavior I need and works without any issues. However, every time I deploy my cloud functions I'm greeted with over 50 warnings that:

path is deprecated: Removed in next major release to match Web SDK typings.

The terminal call that creates these warnings is:

Running command: npm --prefix "$RESOURCE_DIR" run lint

Without the path variable, I'd have to create a custom function to create a path from the DatabaseReference's key and parent keys. That sounds absurd. Is this possibly a lint issue?

There's nothing to indicate in the documentation that they're removing the path variable, and I hate seeing this warning spammed every time I deploy my functions. Is this a legitimate warning, and if so, is there a replacement way of getting the path from a DatabaseReference built into the sdk?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

云淡月浅 2025-01-31 02:40:24

路径属性在节点sdk的第9+版本中弃用 -

尝试do ref.tostring()并删除基本网址

var adaRef = firebase.database().ref("users/ada");

adaRef.toString()

将打印完整的URL:https://firebaseio.com/users/ada
因此,要了解路径,您将其从那里构成。这两种方法是:

adaRef.toString().substring(firebase.database().ref().toString().length-1)

或:

adaRef.toString().substring(adaRef.root.toString().length-1)

两者都将打印/用户/ADA

查看此拉请求 [1] 在Admin SDK开放源存储库上,看来Path属性被弃用以在JavaScript/Web SDK和Node.js Admin SDK之间创建类型兼容性。

Firebase实时数据库的客户端JavaScript SDK从未具有路径属性。获取路径的方法一直是显式调用ToString(),或在字符串串联中包含参考。

path property deprecated in version 9+ of the node SDK –

Try do a ref.toString() and remove the base URL

Consider:

var adaRef = firebase.database().ref("users/ada");

adaRef.toString()

Will print the full URL: https://firebaseio.com/users/ada
So to just get the path, you substring it out of there. Two ways of doing that are:

adaRef.toString().substring(firebase.database().ref().toString().length-1)

Or:

adaRef.toString().substring(adaRef.root.toString().length-1)

both will print /users/ada

Looking at this pull request[1] on the Admin SDK open-source repo, it looks like the path property was deprecated to create type compatibility between the JavaScript/web SDK and the Node.js Admin SDK.

The client-side JavaScript SDK for Firebase Realtime Database never had a path property. The way to get the path has always been to call toString() explicitly, or to include the reference in a string concatenation.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文