-
Notifications
You must be signed in to change notification settings - Fork 1.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add upsert functionality to DefaultCrudRepository #2550
Comments
@elv1s indeed is a good feature. The legacy-juggler implements the Actually the async create(record: MyModel): Promise<MyModel> {
try {
await this.replaceById(record.id, record);
} catch {
record = await super.create(record);
}
return record;
} |
Thanks for the workaround code @marioestradarosa! |
This issue has been marked stale because it has not seen activity within six months. If you believe this to be in error, please contact one of the code owners, listed in the |
This issue has been closed due to continued inactivity. Thank you for your understanding. If you believe this to be in error, please contact one of the code owners, listed in the |
Feature proposal
Add upsert functionality to DefaultCrudRepository
http://apidocs.loopback.io/loopback/#persistedmodel-upsert
Our GUI team would like the ability to call an API endpoint with POST and either create a new object or update an existing object.
Because of race conditions I think this functionality needs to be pushed into the database layer and have the data connector responsible for find/create/update.
Maybe this should just be handled by implementing repository
execute()
Another option would be to check existence of primary key to switch on
updateById
orcreate
.I guess this issue is more of a question of if
upsert
needs to be carried forward to LB4.The text was updated successfully, but these errors were encountered: