build/rekord.js
function(model, cascade, options)
  {
    var db = this;

    if ( model.$isDeleted() )
    {
      Rekord.debug( Rekord.Debugs.SAVE_DELETED, db, model );

      return;
    }

    var key = model.$key();
    var existing = db.models.has( key );

    if ( existing )
    {
      db.trigger( Database.Events.ModelUpdated, [model] );

      model.$trigger( Model.Events.UpdateAndSave );
    }
    else
    {
      db.saveReference( model, key );
      db.trigger( Database.Events.ModelAdded, [model] );
      db.updated();

      model.$trigger( Model.Events.CreateAndSave );
    }

    model.$addOperation( SaveLocal, cascade, options );
  }
function(model, cascade, options)
  {
    var db = this;

    if ( model.$isDeleted() )
    {
      Rekord.debug( Rekord.Debugs.SAVE_DELETED, db, model );

      return;
    }

    var key = model.$key();
    var existing = db.models.has( key );

    if ( existing )
    {
      db.trigger( Database.Events.ModelUpdated, [model] );

      model.$trigger( Model.Events.UpdateAndSave );
    }
    else
    {
      db.saveReference( model, key );
      db.trigger( Database.Events.ModelAdded, [model] );
      db.updated();

      model.$trigger( Model.Events.CreateAndSave );
    }

    model.$addOperation( SaveLocal, cascade, options );
  }
function ( model , cascade , options ) { var db = this ; if ( model . $isDeleted ( ) ) { Rekord . debug ( Rekord . Debugs . SAVE_DELETED , db , model ) ; return ; } var key = model . $key ( ) ; var existing = db . models . has ( key ) ; if ( existing ) { db . trigger ( Database . Events . ModelUpdated , [ model ] ) ; model . $trigger ( Model . Events . UpdateAndSave ) ; } else { db . saveReference ( model , key ) ; db . trigger ( Database . Events . ModelAdded , [ model ] ) ; db . updated ( ) ; model . $trigger ( Model . Events . CreateAndSave ) ; } model . $addOperation ( SaveLocal , cascade , options ) ; }
Save the model
Save the model