mongodb / laravel-mongodb

A MongoDB based Eloquent model and Query builder for Laravel (Moloquent)
https://www.mongodb.com/compatibility/mongodb-laravel-integration
MIT License
6.96k stars 1.42k forks source link

PHPORM-180 Keep createOrFirst in 2 commands to simplify implementation #2984

Closed GromNaN closed 1 month ago

GromNaN commented 1 month ago

Fix PHPORM-180 Alternative to #2980

Revert optimisation from #2742 in order to keep all the processes from Eloquent and simplify maintenance.

The main feature difference is that it's requiring a unique index whereas my previous implementation was only using the filter "attributes". This new implementation is closer to Laravel's implementation, it only removes the nested transaction and catch the MongoDB exception instead of the PDO exception.

Checklist

GromNaN commented 1 month ago

Unfortunately, that doesn't solve the nested transaction issue reported initially #2720.

MongoDB\Driver\Exception\CommandException: Transaction with { txnNumber: 1 } has been aborted.