本文介绍了合并$ FirebaseObject和多位置更新的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
有一种方法可以在使用$ FirebaseObject时进行多位置更新吗?当我尝试这样做时,出现一个错误Firebase.update failed :第一个参数在属性
var customerData = {};中包含一个无效的键($ id)
customerData [Customers /+ user.uid] = firebaseObject;
customerData [ProjectOverview /+ user.uid] =value;
ref.update(customerData);
我可以在,但这似乎不是最好的方法来做到这一点。
有没有更好的方法来使用$ FirebaseObject进行多位置更新?
解决方案
您可以使用 $ firebaseUtils.toJSON()
, AngularFire在它的 $ save()
方法中使用:
var customerData = {};
customerData [Customers /+ user.uid] = $ firebaseUtils.toJSON(firebaseObject);
customerData [ProjectOverview /+ user.uid] =value;
ref.update(customerData);
Is there a way to do a multi-location update when using a $FirebaseObject?
When i try it like this i get an error "Firebase.update failed: First argument contains an invalid key ($id) in property"
var customerData = {};
customerData["Customers/" + user.uid] = firebaseObject;
customerData["ProjectOverview/" + user.uid] = "value";
ref.update(customerData);
I could use the solution in this SO question but that doesn't seem like the best way to do this.
Is there a better way to do multi-location updates when using a $FirebaseObject?
解决方案
You can use $firebaseUtils.toJSON()
, which AngularFire uses in its $save()
method:
var customerData = {};
customerData["Customers/" + user.uid] = $firebaseUtils.toJSON(firebaseObject);
customerData["ProjectOverview/" + user.uid] = "value";
ref.update(customerData);
这篇关于合并$ FirebaseObject和多位置更新的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!