【问题标题】:Firebase multi location update best practice(samples included) iosFirebase 多位置更新最佳实践(包括示例)ios
【发布时间】:2016-12-05 18:35:15
【问题描述】:

我对 Firebase 还是很陌生,而且我可以看到他们的功能到目前为止我很喜欢它。我计划在未来继续使用它,但我想使用可能的最佳实践,所以我试图在 Firebase 中进行多位置更新, 我让它以两种方式工作,但我想确定哪一种是正确的、最好的方式,我想知道为什么。

第一种方式:

NSDictionary *childUpdates = @{
                                       [[NSString stringWithFormat:@"/%@/",IDMAllIDMsPathFIR] stringByAppendingString:key]:idmData,
                                       [NSString stringWithFormat:@"/%@/%@/%@/", IDMUserIDMsPathFIR,self.currentFirebaseUserId, key]: idmData
                                       };
        [self.databaseReference updateChildValues:childUpdates];

第二种方式是这样的:

  FIRDatabaseReference * allIDMsRef = [[self.databaseReference child:IDMAllIDMsPathFIR] child:key];
    FIRDatabaseReference * userIDMsRef = [[[self.databaseReference child:IDMUserIDMsPathFIR] child:self.currentFirebaseUserId] child:key];

    [userIDMsRef updateChildValues:idmData];
    [allIDMsRef updateChildValues:idmData];

self.databaseReference 是 Firebase 数据库的根引用

请让我知道哪个更好以及为什么更好,我非常感谢对此的任何想法。

【问题讨论】:

    标签: ios objective-c firebase firebase-realtime-database


    【解决方案1】:

    我只想说第一种方法更好。一切都解释得很清楚here

    【讨论】:

    • 谢谢你,我希望有人能更深入地解释它,否则我会接受你的回答并继续使用第一种方法。
    猜你喜欢
    • 2013-07-31
    • 1970-01-01
    • 1970-01-01
    • 2015-09-08
    • 2011-04-08
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多