Created
December 24, 2015 15:59
-
-
Save yamikuronue/1668df4981a589e2a974 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
ensureGameExists: function(id) { | |
return internals.db.prepare('SELECT id FROM games WHERE id = ?') | |
.then((statement) => { | |
return statement.get(id); | |
}) | |
then((row) => { | |
if (!row) { | |
return internals.db.prepare('INSERT INTO games (id, status, current_day, current_stage) VALUES (?, (SELECT id FROM game_statuses WHERE status="active"),0,(SELECT id FROM stages WHERE stage="night"))') | |
.then((statement) => { | |
return statement.run(id) | |
}) | |
} else { | |
return Q(true); | |
} | |
}); | |
}, |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment