Firebase data consistency across multiple nodes -
according the firebase docs data flattened , indices used link different nodes in tree:
users $userid widgets $widgetid widgets $widgetid
in above example, if user creates widget, widgetid
stored under user node.
my question whether there way guarantee consistency of operation, considering there more 1 write required.
assuming first operation is:
var newkey = fb.child('widgets').push({ name: 'widge' }).key();
i can write to:
fb.child('users').child(auth.id).child('widgets').child(newkey).set(true);
but if there failure or other problem between 2 writes? or if have multiple places need store key , failure occurs between writes?
is there way handle in firebase?
if not, there plans support in future?
and if so, can provide specific example of how done?
note part of core firebase api. see this blog post details.
var mergedupdate = {}; mergedupdate[ 'users/' + userid + '/widgets/' + widgetid ] = true; mergedupdate[ 'widgets/' + widgetid ] = widgetdata; var ref = new firebase("https://<your-firebase-app>.firebaseio.com/"); ref.update(mergedupdate);
Comments
Post a Comment