Firebase批量更新/删除 [英] Firebase Bulk Update / Delete

查看:64
本文介绍了Firebase批量更新/删除的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用Swift和Firebase 3构建一个聊天应用程序,我想知道如何处理多个消息的删除/更新.例如,如果一个用户决定删除一个对话,我想删除/更新该对话中所有消息的标记.

I'm building a chat app using Swift and Firebase 3 and I'm wondering how one would handle multiple message deletes / updates. For example, if one user decides to delete a conversation, I would like to delete / update a flag on all the messages in that conversation.

是否可以使用Swift和Firebase 3做到这一点?也许使用REST请求? 我在他们的文档中找不到与此相关的内容.

Is there a way to do this with Swift and Firebase 3? Maybe using a REST request? I was unable to find something related to this in their documentation.

如果Firebase尚不支持此功能,那么标记最后一条消息,然后以相反的顺序下载消息(从最新的开始),然后仅在标记的消息处停止,是个好方法吗?

If this is not yet supported in Firebase, is it a good approach to flag the last message and then download the messages in reverse order (starting from the newest), and just stop at the flagged message?

谢谢.

推荐答案

您可以轻松地使用"updateChildValues"做到这一点,并根据需要选择一个常见祖先的引用.

You can easily do it with "updateChildValues", picking a ref that's a common ancestor all the way to root if needed.

这是一个例子:

     [super.ref updateChildValues:@{
                       [NSString stringWithFormat:@"followers/%@/%@", _user.userID,
                        [FPAppState sharedInstance].currentUser.userID]: lastPostID,
                       [NSString stringWithFormat:@"people/%@/following/%@",
                        [FPAppState sharedInstance].currentUser.userID, _user.userID]: @YES
                       }];

https://github.com/firebase/friendlypix/blob/master/ios/FriendlyPix/FPAccountViewController.m#L114

这篇关于Firebase批量更新/删除的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆