From 7ca55020d5f0a307b665a146d34886f7ccb04b80 Mon Sep 17 00:00:00 2001 From: Nathan Hutchision Date: Thu, 8 Jan 2015 16:01:39 +1100 Subject: [PATCH] expose Firebase.update Update is very handy for updating single hash attributes without deleting the other attributes in the same key --- src.js | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src.js b/src.js index 855d620..d397c45 100644 --- a/src.js +++ b/src.js @@ -86,6 +86,12 @@ var createRefForReals = (Firebase, path, routes, host) => { validateHash(val, path, routes, matchInfo); firebaseRef.set(val, cb); }; + var update = (val, cb) => { + handler.validate(val, path); + if (handler === hash) + validateHash(val, path, routes, matchInfo); + firebaseRef.update(val, cb); + }; var push = (obj, cb) => { validatePush(obj, path, routes, matchInfo); firebaseRef.push(obj, cb); @@ -124,7 +130,7 @@ var createRefForReals = (Firebase, path, routes, host) => { }; var removeChangeListener = () => { }; - return { set:set, getValue, push, child, listen }; + return { set:set, update, getValue, push, child, listen }; }; var transformHash = (child, routes, path) => {