2016-07-27 80 views
2

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

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

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

在此先感谢。

+0

看看[我这篇文章(https://firebase.googleblog.com/2015/09/introducing-multi-location-updates- and_86.html)。你在找什么? –

+0

是的。谢谢! 这适用于更新,关于如何删除多个孩子的任何想法? – florinzf

+0

您可以通过将其值设置为空来删除子项。 –

回答

2

你可以使用“updateChildValues”轻松做到这一点,如果需要的话,选择一个通用祖先的引用。

下面是一个例子:

 [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

+0

谢谢!这适用于更新。 您对如何删除多个孩子有任何想法吗? – florinzf

+0

您可以将它们的值设置为[NSNull null] –