src/database/FirebaseArray.js
function(indexOrItem) {
          this._assertNotDestroyed('$save');
          var self = this;
          var item = self._resolveItem(indexOrItem);
          var key = self.$keyAt(item);
          var def = $q.defer();

          if( key !== null ) {
            var ref = self.$ref().ref.child(key);
            var dataJSON;

            try {
              dataJSON = $firebaseUtils.toJSON(item);
            } catch (err) {
              def.reject(err);
            }

            if (typeof dataJSON !== 'undefined') {
              $firebaseUtils.doSet(ref, dataJSON).then(function() {
                self.$$notify('child_changed', key);
                def.resolve(ref);
              }).catch(def.reject);
            }
          }
          else {
            def.reject('Invalid record; could not determine key for '+indexOrItem);
          }

          return def.promise;
        }
function(indexOrItem) {
          this._assertNotDestroyed('$save');
          var self = this;
          var item = self._resolveItem(indexOrItem);
          var key = self.$keyAt(item);
          var def = $q.defer();

          if( key !== null ) {
            var ref = self.$ref().ref.child(key);
            var dataJSON;

            try {
              dataJSON = $firebaseUtils.toJSON(item);
            } catch (err) {
              def.reject(err);
            }

            if (typeof dataJSON !== 'undefined') {
              $firebaseUtils.doSet(ref, dataJSON).then(function() {
                self.$$notify('child_changed', key);
                def.resolve(ref);
              }).catch(def.reject);
            }
          }
          else {
            def.reject('Invalid record; could not determine key for '+indexOrItem);
          }

          return def.promise;
        }
function ( indexOrItem ) { this . _assertNotDestroyed ( '$save' ) ; var self = this ; var item = self . _resolveItem ( indexOrItem ) ; var key = self . $keyAt ( item ) ; var def = $q . defer ( ) ; if ( key !== null ) { var ref = self . $ref ( ) . ref . child ( key ) ; var dataJSON ; try { dataJSON = $firebaseUtils . toJSON ( item ) ; } catch ( err ) { def . reject ( err ) ; } if ( typeof dataJSON !== 'undefined' ) { $firebaseUtils . doSet ( ref , dataJSON ) . then ( function ( ) { self . $$notify ( 'child_changed' , key ) ; def . resolve ( ref ) ; } ) . catch ( def . reject ) ; } } else { def . reject ( 'Invalid record; could not determine key for ' + indexOrItem ) ; } return def . promise ; }
Pass either an item in the array or the index of an item and it will be saved back
to Firebase. While the array is read-only and its structure should not be changed,
it is okay to modify properties on the objects it contains and then save those back
individually.

Returns a future which is resolved when the data has successfully saved to the server.
The resolve callback will be passed a Firebase ref representing the saved element.
If passed an invalid index or an object which is not a record in this array,
the promise will be rejected.

@param {int|object} indexOrItem
@returns a promise resolved after data is saved
Pass either an item in the array or the index of an item and it will be saved back to Firebase . While the array is read - only and its structure should not be changed it is okay to modify properties on the objects it contains and then save those back individually .