Get a Quote Right Now

Edit Template

Update values ON CONFLICT

If the values you are trying to insert conflict due to existing data the orUpdate function can be used to update specific values on the conflicted target.

await datasource
    .createQueryBuilder()
    .insert()
    .into(User)
    .values({
        firstName: "Timber",
        lastName: "Saw",
        externalId: "abc123",
    })
    .orUpdate(
        ["firstName", "lastName"],
        ["externalId"],
    )
    .execute()

Share

Leave a Reply

Your email address will not be published. Required fields are marked *