admin管理员组文章数量:1355758
I had some apps that used the multi-location update method as below:
const updates = [];
updates['/location1'] = data;
updates['/location2'] = data2;
firebase.database().ref().update(updates);
Yet, as I'm developing a new app, I got the following message:
FIREBASE WARNING: Passing an Array to Firebase.update() is deprecated. Use set() if you want to overwrite the existing data, or an Object with integer keys if you really do want to only update some of the children.
With no real info anywhere about how to perform multi-location atomic updates anywhere, and the docs are still with the old method. Chaining then()
is not a good idea, as it would be a nightmare to rollback.
Any clues and/or information on new multi-location updates methods?
I had some apps that used the multi-location update method as below:
const updates = [];
updates['/location1'] = data;
updates['/location2'] = data2;
firebase.database().ref().update(updates);
Yet, as I'm developing a new app, I got the following message:
FIREBASE WARNING: Passing an Array to Firebase.update() is deprecated. Use set() if you want to overwrite the existing data, or an Object with integer keys if you really do want to only update some of the children.
With no real info anywhere about how to perform multi-location atomic updates anywhere, and the docs are still with the old method. Chaining then()
is not a good idea, as it would be a nightmare to rollback.
Any clues and/or information on new multi-location updates methods?
Share Improve this question edited Jun 8, 2017 at 20:14 Frank van Puffelen 600k85 gold badges890 silver badges860 bronze badges asked Jun 8, 2017 at 20:13 jacques mouettejacques mouette 3833 silver badges9 bronze badges1 Answer
Reset to default 14I didn't even know you could pass an array, but that would definitely not work as both values would then be overlapping updates.
You should instead pass an object:
const updates = {}; // this line is different
updates['/location1'] = data;
updates['/location2'] = data2;
firebase.database().ref().update(updates);
The array syntax we use for setting properties works on a JavaScript object too.
本文标签: javascriptFirebaseMultilocation updates method deprecatedwhat nowStack Overflow
版权声明:本文标题:javascript - Firebase - Multi-location updates method deprecated, what now? - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1743985147a2571246.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论