结合 $FirebaseObject 和多位置更新 [英] Combine $FirebaseObject and multi location updates
问题描述
有没有办法在使用 $FirebaseObject 时进行多位置更新?
Is there a way to do a multi-location update when using a $FirebaseObject?
当我这样尝试时,出现错误Firebase.update 失败:第一个参数在属性中包含无效的键 ($id)"
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);
我可以使用 this SO question中的解决方案 但这似乎不是最好的方法.
I could use the solution in this SO question but that doesn't seem like the best way to do this.
在使用 $FirebaseObject 时是否有更好的方法来进行多位置更新?
Is there a better way to do multi-location updates when using a $FirebaseObject?
推荐答案
您可以使用 $firebaseUtils.toJSON()
,其中 AngularFire 在其 $save()
方法 中使用:
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 和多位置更新的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!