Skip to content

Instantly share code, notes, and snippets.

@avimar
Created July 27, 2016 08:05
Show Gist options
  • Save avimar/cdda55c4296456fe86887df1d84e643c to your computer and use it in GitHub Desktop.
Save avimar/cdda55c4296456fe86887df1d84e643c to your computer and use it in GitHub Desktop.
var _putItem = function (item, shouldCreateNewItem, shouldReturnInformationFromJoinedTable) {
return knex(...).update()
.then(function(affectedRows) {
if (affectedRows == 0 && shouldCreateNewItem) return knex.insert(...);
else if (shouldReturnInformationFromJoinedTable) return knex(...). ....leftJoin(..).select().first()
else return true;
})
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment