Last active
May 27, 2022 18:37
-
-
Save lewiswalsh/e296c81d0dbb909937679ed78917712c to your computer and use it in GitHub Desktop.
KnexJS 'upsert', update on duplicate key else insert #knex #mysql
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
knex(TABLE_NAME) | |
.insert({ data : data }) | |
.onConflict(PRIMARY_KEY) | |
.merge() | |
.then((res) => { | |
... | |
}) | |
.catch((err) => { | |
... | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment