![](/img/trans.png)
[英]iOS Firebase -How to create multi node location update using .childByAutoId()
[英]Firebase multi location update best practice(samples included) ios
我对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数据库的根参考
请让我知道哪个更好,为什么更好,我对此表示感谢。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.