问题
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?
回答1:
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);
来源:https://stackoverflow.com/questions/36845931/combine-firebaseobject-and-multi-location-updates