Combine $FirebaseObject and multi location updates

你。 提交于 2019-12-13 11:19:12

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!