Upsert implementation
See original GitHub issueIs your feature request related to a problem? Please describe. A clarification on a possible feature
I’m going to create a CustomBaseRepository
to implement a generic method to find or create (upsert). Can you point me to some example on how to create such a base repository? The documentation (https://mikro-orm.io/docs/repositories#custom-repository) si not very exhaustive and the links provided have no example for a custom base repository.
Alternatively, does such method exist already?
Issue Analytics
- State:
- Created 4 years ago
- Reactions:1
- Comments:10 (5 by maintainers)
Top Results From Across the Web
UPSERT - PostgreSQL wiki
"UPSERT" is a DBMS feature that allows a DML statement's author to atomically either insert a row, or on the basis of the...
Read more >Upsert in SQL: What is an upsert, and when should you use ...
The UPSERT command in CockroachDB performs an upsert based on the uniqueness of the primary key column or columns, and it will perform...
Read more >What is UPSERT and how to do it in MySQL - Linux Hint
Here we learned that UPSERT is a combination of two words Update and Insert. It works on the following principle that, if the...
Read more >Upsert | Android Developers
The implementation of the method will insert its parameters into the database if it does not already exists (checked by primary key). If...
Read more >Use a staging table to perform a merge (upsert)
Use a staging table to perform a merge (upsert). PDFRSS. You can efficiently update and insert new data by loading your data into...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Its pretty simple, all what repository does is that it forwards calls to the entity manager with the entity name stored in
this.entityName
. But you can use the repository methods directly so it will be handled for you:Just create a generic class extending
EntityRepository
and pass it in the ORM config viaMikroORM.init({ entityRepository: CustomBaseRepository })
.Something like this should work:
Nope.
Not sure if I understood well, do you also need help with implementation of the upsert method? Should be quite trivial.