2016-07-27 83 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] –