【问题标题】:Add/Remove List item from firebase using rest api使用rest api从firebase添加/删除列表项
【发布时间】:2016-12-30 04:15:35
【问题描述】:

我无法使用 firebase rest ApI 向 childGroups 列表添加/删除项目。

以下是我尝试按值删除 childGroup 项的其余 api 调用,但没有成功。有人可以帮忙吗?

我也无法弄清楚为 childGroup 添加价值的其余 api 是什么。

删除https://moe-90cc7.firebaseio.com/subscriber/GYlSDXx0Kwh7AerOzFGf8MDmhOg1/chatGroups/GYlSDXx0Kwh7AerOzFGf8MDmhOg1-UrXBTpOMhGSTFTXRRVRmUPPzYuU2.json

【问题讨论】:

    标签: firebase firebase-realtime-database nosql


    【解决方案1】:

    当您使用 REST API 删除节点时,您需要指定要删除的 key 的路径。 chatGroups 下没有 GYlSDXx0Kwh7AerOzFGf8MDmhOg1-UrXBTpOMhGSTFTXRRVRmUPPzYuU2 键,因此没有任何内容被删除。

    您要删除的值在键 0 下,因此:DELETE https://moe-90cc7.firebaseio.com/subscriber/GYlSDXx0Kwh7AerOzFGf8MDmhOg1/chatGroups/0.json

    请注意,习惯上在 Firebase 中将类似集合的数据结构存储为

    subscriber
      GYlSDXx0Kwh7AerOzFGf8MDmhOg1
        chatGroups
          "GYlSDXx0Kwh7AerOzFGf8MDmhOg1-UrXBTpOMhGSTFTXRRVRmUPPzYuU2": true
    

    这样做的好处是组是自动唯一的,并且多次添加同一个组是幂等操作。

    【讨论】:

    • 谢谢弗兰克,我也被从 geofire 检索数据卡住了。找不到文档..您知道与 geofire 和 rest api 调用的任何链接吗?
    猜你喜欢
    • 1970-01-01
    • 2021-05-18
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-09-19
    • 1970-01-01
    • 2017-09-16
    相关资源
    最近更新 更多