This repository was archived by the owner on Apr 4, 2023. It is now read-only.
File tree Expand file tree Collapse file tree 2 files changed +17
-0
lines changed Expand file tree Collapse file tree 2 files changed +17
-0
lines changed Original file line number Diff line number Diff line change @@ -1111,7 +1111,15 @@ firebase.setValue = function (path, val) {
11111111firebase . update = function ( path , val ) {
11121112 return new Promise ( function ( resolve , reject ) {
11131113 try {
1114+ if ( typeof val == "object" ) {
11141115 firebase . instance . child ( path ) . updateChildren ( firebase . toHashMap ( val ) ) ;
1116+ } else {
1117+ var lastPartOfPath = path . lastIndexOf ( "/" ) ;
1118+ var pathPrefix = path . substring ( 0 , lastPartOfPath ) ;
1119+ var pathSuffix = path . substring ( lastPartOfPath + 1 ) ;
1120+ var updateObject = '{"' + pathSuffix + '" : "' + val + '"}' ;
1121+ firebase . instance . child ( pathPrefix ) . updateChildren ( firebase . toHashMap ( JSON . parse ( updateObject ) ) ) ;
1122+ }
11151123 resolve ( ) ;
11161124 } catch ( ex ) {
11171125 console . log ( "Error in firebase.update: " + ex ) ;
Original file line number Diff line number Diff line change @@ -1230,7 +1230,16 @@ firebase.setValue = function (path, val) {
12301230firebase . update = function ( path , val ) {
12311231 return new Promise ( function ( resolve , reject ) {
12321232 try {
1233+ if ( typeof val == "object" ) {
12331234 firebase . instance . childByAppendingPath ( path ) . updateChildValues ( val ) ;
1235+ } else {
1236+ var lastPartOfPath = path . lastIndexOf ( "/" ) ;
1237+ var pathPrefix = path . substring ( 0 , lastPartOfPath ) ;
1238+ var pathSuffix = path . substring ( lastPartOfPath + 1 ) ;
1239+ var updateObject = '{"' + pathSuffix + '" : "' + val + '"}' ;
1240+ firebase . instance . childByAppendingPath ( pathPrefix ) . updateChildValues ( JSON . parse ( updateObject ) ) ;
1241+ }
1242+
12341243 resolve ( ) ;
12351244 } catch ( ex ) {
12361245 console . log ( "Error in firebase.update: " + ex ) ;
You can’t perform that action at this time.
0 commit comments