我对 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数据库的根引用
请让我知道哪一个更好以及为什么更好,我真的很感激对此的任何想法。
最佳答案
我只想说第一种方法更好。一切都解释得很清楚here .
关于ios - Firebase 多位置更新最佳实践(包括示例)ios,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40971913/