Is there something 'native' to MYSQL that does an Update OR Create?
Something that is more performative than SELECT, validation, and INSERT / UPDATE as usual.
I do not mean methods that simplify this via application, my doubt is about this action under the responsibility of the database itself.
Example of how to use it in Laravel:
App\Flight::updateOrCreate(
['departure' => 'Oakland', 'destination' => 'San Diego'],
['price' => 99]
);
However, this is only an abstraction of SELECT and condition.
In MongoDB, we have this:
Person.update(
{ name : 'TED' },
{ name : 'TED', age : 50 },
{ upsert : true }
,callback );
The upsert
parameter causes update or create to work.