gpt4 book ai didi

swift - Firebase 批量更新/删除

转载 作者:可可西里 更新时间:2023-11-01 01:34:47 25 4
gpt4 key购买 nike

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

有没有办法用 Swift 和 Firebase 3 做到这一点?也许使用 REST 请求?我无法在他们的文档中找到与此相关的内容。

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

提前致谢。

最佳答案

您可以使用“updateChildValues”轻松做到这一点,如果需要的话,选择一个一直到 root 的共同祖先的 ref。

这是一个例子:

     [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

关于swift - Firebase 批量更新/删除,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38613384/

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