#typeorm ghost methods?

6 messages · Page 1 of 1 (latest)

plucky flower
#

No these methods are coming from typeorm itself. Update sends a single update query to update the resource. The difference between update and save is that save first checks if the record exists by sending a select query. If it does, it performs an update, otherwise it inserts. Also save is able to perform cascades

#

About upsert, it adds ON CONFLICT DO UPDATE to the generated SQL for postgres which either performes and insert or update in a single query. MySQL equivalent of that is ON DUPLICATE KEY UPDATE

trim quail
#

https://typeorm.io/repository-api

update - Partially updates entity by a given update options or entity id.
...
upsert - Inserts a new entity or array of entities unless they already exist in which case they are updated instead. Supported by AuroraDataApi, Cockroach, Mysql, Postgres, and Sqlite database drivers.
...

worldly girder
worldly girder
#

thanks @plucky flower and @trim quail