src/models/model.js
/**
       * Concurrency support: strategy is to merge with
       * last update vs blindly overwriting. Concomitant
       * strategy is to add props dynamically as needed
       * to minimize the potential for conflict. If
       * updating same props, last one in wins.
       *
       * @param {*} changes - object containing updated props
       * @param {boolean} validate - run validation by default
       * @param {boolean} overwrite - do not merge with last saved
       * copy - the default behavior is to merge
       */
Concurrency support: strategy is to merge with
last update vs blindly overwriting. Concomitant
strategy is to add props dynamically as needed
to minimize the potential for conflict. If
updating same props, last one in wins.

@param {*} changes - object containing updated props
@param {boolean} validate - run validation by default
@param {boolean} overwrite - do not merge with last saved
copy - the default behavior is to merge
Concurrency support : strategy is to merge with last update vs blindly overwriting . Concomitant strategy is to add props dynamically as needed to minimize the potential for conflict . If updating same props last one in wins . @param { * } changes - object containing updated props @param { boolean } validate - run validation by default @param { boolean } overwrite - do not merge with last saved copy - the default behavior is to merge
async update(changes, validate = true, overwrite = false) {
        const model = optionalValidation(this, changes, validate);
        const saved = await datasource.find(model[ID]);
        const merge = overwrite ? model : { ...saved, ...model };
        const truth = await datasource.save(model[ID], {
          ...merge,
          [UPDATETIME]: new Date().getTime(),
        });
        await this.emit("saveModel", truth);
        return truth;
      }
async update ( changes , validate = true , overwrite = false ) { const model = optionalValidation ( this , changes , validate ) ; const saved = await datasource . find ( model [ ID ] ) ; const merge = overwrite ? model : { ... saved , ... model } ; const truth = await datasource . save ( model [ ID ] , { ... merge , [ UPDATETIME ] : new Date ( ) . getTime ( ) , } ) ; await this . emit ( "saveModel" , truth ) ; return truth ; }
Concurrency support: strategy is to merge with
 last update vs blindly overwriting.
Concurrency support : strategy is to merge with last update vs blindly overwriting .
// by default merge the incoming model with the last one saved // notify interested parties about this