Ask Your Question
4

What does TypeORM upsert do for creating if it does not already exist?

asked 2023-02-18 11:00:00 +0000

plato gravatar image

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
2

answered 2022-11-15 08:00:00 +0000

woof gravatar image

When using TypeORM's upsert (also known as createQueryBuilder().insert().onConflict().execute()), if a record with the given unique constraint already exists in the database, it will update the existing record with the values provided. Otherwise, it will create a new record with the provided values. In other words, upsert will attempt to insert a new record, but if a record with the same unique key already exists, it will instead update the existing record with the new values.

edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account. This space is reserved only for answers. If you would like to engage in a discussion, please instead post a comment under the question or an answer that you would like to discuss

Add Answer


Question Tools

Stats

Asked: 2023-02-18 11:00:00 +0000

Seen: 10 times

Last updated: Nov 15 '22