Skip to content

Instantly share code, notes, and snippets.

@Meekohi
Created November 22, 2013 16:57
Show Gist options
  • Select an option

  • Save Meekohi/7603210 to your computer and use it in GitHub Desktop.

Select an option

Save Meekohi/7603210 to your computer and use it in GitHub Desktop.
function initDbHashAndFirstRun() {
return when(models.Settings.read('dbHash')).then(function (dbhash) {
// we already ran this, chill
self.dbHash = dbhash.attributes.value;
return dbhash.attributes.value;
}).otherwise(function (error) {
// this is where all the "first run" functionality should go
var dbhash = uuid.v4();
return when(models.Settings.add({key: 'dbHash', value: dbhash, type: 'core'})).then(function () {
self.dbHash = dbhash;
return dbhash;
}).then(doFirstRun);
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment