server/boot/load-model.js
function updateSnapshot(app, uid, cb) {
  logger.debug('updateSnapshot entry');

  app.models.snapshot.findOne(
    { where: { current: 'true' } },
    function(err, instance) {
      if (err) {
        // fall through assuming there was no current
      } else if (instance) {
        instance.updateAttributes(
          { current: 'false' },
          function(err, instance) {
            if (err) {
              // fall through assuming instance was deleted
            }
          });
        releaseSnapshot(app, instance.id);
      }
    });

  app.models.snapshot.findById(uid, function(err, instance) {
    if (err) {
      logger.debug('updateSnapshot error(1)');
      cb(err);
      return;
    }

    instance.updateAttributes(
      { current: 'true' },
      function(err, instance) {
        if (err) {
          logger.debug('updateSnapshot error(2)');
          cb(err);
          return;
        }
        logger.debug('updateSnapshot exit');
        cb();
      });
  });
}
function updateSnapshot(app, uid, cb) {
  logger.debug('updateSnapshot entry');

  app.models.snapshot.findOne(
    { where: { current: 'true' } },
    function(err, instance) {
      if (err) {
        // fall through assuming there was no current
      } else if (instance) {
        instance.updateAttributes(
          { current: 'false' },
          function(err, instance) {
            if (err) {
              // fall through assuming instance was deleted
            }
          });
        releaseSnapshot(app, instance.id);
      }
    });

  app.models.snapshot.findById(uid, function(err, instance) {
    if (err) {
      logger.debug('updateSnapshot error(1)');
      cb(err);
      return;
    }

    instance.updateAttributes(
      { current: 'true' },
      function(err, instance) {
        if (err) {
          logger.debug('updateSnapshot error(2)');
          cb(err);
          return;
        }
        logger.debug('updateSnapshot exit');
        cb();
      });
  });
}
function updateSnapshot ( app , uid , cb ) { logger . debug ( 'updateSnapshot entry' ) ; app . models . snapshot . findOne ( { where : { current : 'true' } } , function ( err , instance ) { if ( err ) { // fall through assuming there was no current } else if ( instance ) { instance . updateAttributes ( { current : 'false' } , function ( err , instance ) { if ( err ) { // fall through assuming instance was deleted } } ) ; releaseSnapshot ( app , instance . id ) ; } } ) ; app . models . snapshot . findById ( uid , function ( err , instance ) { if ( err ) { logger . debug ( 'updateSnapshot error(1)' ) ; cb ( err ) ; return ; } instance . updateAttributes ( { current : 'true' } , function ( err , instance ) { if ( err ) { logger . debug ( 'updateSnapshot error(2)' ) ; cb ( err ) ; return ; } logger . debug ( 'updateSnapshot exit' ) ; cb ( ) ; } ) ; } ) ; }
Updates snapshot instance in snapshot model to reflect 'current'
@param {???} app - loopback application
@param {string} uid - snapshot identifier
@param {callback} cb - callback that handles error or successful completion
Updates snapshot instance in snapshot model to reflect current