laravel-mongodb icon indicating copy to clipboard operation
laravel-mongodb copied to clipboard

Add transaction support

Open klinson opened this issue 4 years ago • 42 comments

requires mongodb version V4.0 or more and deployment replica sets or sharded clusters transaction support create/insert,update,delete,etc operation Supports infinite-level nested transactions, but outside transaction rollbacks do not affect the commit of inside transactions

DB::beginTransaction();
DB::collection('users')->where('name', 'klinson')->update(['age' => 18]);
DB::transaction(function () {
    DB::collection('users')->where('name', 'mongodb')->update(['age' => 30]);
});
DB::rollBack();

klinson avatar Jan 08 '20 09:01 klinson

@klinson check failed tests in travis build please

Smolevich avatar Jan 08 '20 09:01 Smolevich

@Smolevich Because transaction requires mongodb version V4.0 or more and deployment replica sets or sharded clusters, but your environment doesn't.

klinson avatar Jan 09 '20 01:01 klinson

@klinson, Not my environment, it is common configuration based on official docker images, you can change if it's needed

Smolevich avatar Jan 09 '20 04:01 Smolevich

@klinson if you work on PR, add 'WIP' to title of PR

Smolevich avatar Jan 09 '20 11:01 Smolevich

@Smolevich I've modified the environment to support it

klinson avatar Jan 13 '20 09:01 klinson

@jenssegers i prepare https://github.com/Smolevich/demo-mongo-application/pull/9 for demo. It is not finished, but today i finish

Smolevich avatar Jan 17 '20 08:01 Smolevich

@klinson do you have plans to add changes for PR?

Smolevich avatar Jan 22 '20 13:01 Smolevich

I will continue to change it

klinson avatar Jan 22 '20 13:01 klinson

@klinson do you have plans to work on this PR?

Smolevich avatar Feb 04 '20 21:02 Smolevich

whats your plan about this MR, i need this really. @Smolevich @klinson @jenssegers If you need help or anything i can help to fix this problem i need this immediately. Thanks

bsormagec avatar Feb 07 '20 12:02 bsormagec

Merge master, please @klinson

Giacomo92 avatar Feb 07 '20 13:02 Giacomo92

How to do? @Giacomo92

klinson avatar Feb 07 '20 13:02 klinson

See here @klinson

Giacomo92 avatar Feb 07 '20 13:02 Giacomo92

@divine I will do it today

klinson avatar Feb 13 '20 00:02 klinson

@divine My network can't connect github, I'll try again tomorrow

klinson avatar Feb 13 '20 19:02 klinson

@klinson, please add another testsuite for transactional tests in phpunit.xml and i prepare new ci file for running only transactional tests

Smolevich avatar Feb 16 '20 15:02 Smolevich

For example see https://github.com/jenssegers/laravel-mongodb/blob/master/phpunit.xml.dist#L28

Smolevich avatar Feb 16 '20 15:02 Smolevich

@Smolevich Hello, I am a user of jenssegers/laravel-mongodb. As i see currently there is no support of multi doc transaction handling in jenssegers and you people are working on it. Reference to https://github.com/jenssegers/laravel-mongodb/issues/1334 also. Is there any fix 'temporarily' (until jenssegers comes up) to handle this in laravel along with jenssegers and MongoDb/Client because my code is using jenssegers Models at many places in the code. So i don't want to use raw MongoDb/Client alone which required lot of changes and thus, I want to use MongoDB/Client with jenssegers instead of just MongoDB/Client. Any code snippet will be appreciated. Thanks

talnizer avatar Apr 13 '20 15:04 talnizer

Any update on this ? Is this part of the Develop branch already ?

ksgush1 avatar Jun 24 '20 16:06 ksgush1

Any update on this ? Is this part of the Develop branch already ?

Not part of develop branch. Sorry, still no updates so far.

divine avatar Jun 24 '20 16:06 divine

@Smolevich I have added another testsuite for transactional tests in phpunit.xml.What should I do next?

@talnizer @ksgush1 @divine Sorry, I stopped coding because of the epidemic. Now I'm going to keep completing it.

klinson avatar Jun 28 '20 10:06 klinson

@klinson i will see on your changes and go back with answer

Smolevich avatar Jun 28 '20 10:06 Smolevich

@klinson can you copy part for ci from this PR or i can implemente this functionality at master ?

Smolevich avatar Jul 01 '20 13:07 Smolevich

@Smolevich Can I invite you into the project?

klinson avatar Jul 02 '20 01:07 klinson

Codecov Report

Merging #1904 into master will increase coverage by 0.57%. The diff coverage is 95.91%.

Impacted file tree graph

@@             Coverage Diff              @@
##             master    #1904      +/-   ##
============================================
+ Coverage     86.90%   87.47%   +0.57%     
- Complexity      664      683      +19     
============================================
  Files            33       31       -2     
  Lines          1573     1581       +8     
============================================
+ Hits           1367     1383      +16     
+ Misses          206      198       -8     
Impacted Files Coverage Δ Complexity Δ
src/Jenssegers/Mongodb/Connection.php 91.48% <92.00%> (+0.18%) 47.00 <9.00> (+9.00)
src/Jenssegers/Mongodb/Query/Builder.php 89.77% <100.00%> (+0.50%) 173.00 <3.00> (+10.00)
...gers/Mongodb/Auth/PasswordResetServiceProvider.php 25.00% <0.00%> (-8.34%) 2.00% <0.00%> (ø%)
src/Jenssegers/Mongodb/Collection.php 88.88% <0.00%> (-0.59%) 5.00% <0.00%> (ø%)
src/Jenssegers/Mongodb/Eloquent/Builder.php 87.71% <0.00%> (-0.42%) 22.00% <0.00%> (ø%)
...enssegers/Mongodb/Helpers/QueriesRelationships.php 92.98% <0.00%> (-0.24%) 28.00% <0.00%> (ø%)
src/Jenssegers/Mongodb/Relations/BelongsToMany.php 85.85% <0.00%> (-0.15%) 42.00% <0.00%> (ø%)
src/Jenssegers/Mongodb/Relations/EmbedsMany.php 97.14% <0.00%> (-0.11%) 45.00% <0.00%> (ø%)
src/Jenssegers/Mongodb/Eloquent/Model.php 94.80% <0.00%> (-0.10%) 82.00% <0.00%> (-1.00%)
... and 10 more

Continue to review full report at Codecov.

Legend - Click here to learn more Δ = absolute <relative> (impact), ø = not affected, ? = missing data Powered by Codecov. Last update dd6f667...9e0cfd2. Read the comment docs.

codecov-commenter avatar Jul 21 '20 08:07 codecov-commenter

@klinson well done! Could you please take a loot at @Smolevich https://github.com/jenssegers/laravel-mongodb/pull/1904#discussion_r447489996?

divine avatar Jul 23 '20 05:07 divine

Please merge this PR ? @Smolevich

klinson avatar Aug 03 '20 01:08 klinson

Any news?

tairau avatar Oct 14 '20 00:10 tairau

Any news?

There are important problems that needs to be fixed before merging this so no updates planned for now at least.

Thanks!

divine avatar Oct 14 '20 00:10 divine

Thanks for the answer. What problems still need to be solved? I see practically solved problems in PR.

tairau avatar Oct 14 '20 01:10 tairau

Thanks for the answer. What problems still need to be solved? I see practically solved problems in PR.

  1. Why test are failing?
  2. Problems not related to this PR, however a library itself; see this discussion https://github.com/jenssegers/laravel-mongodb/issues/1974

Thanks!

divine avatar Oct 14 '20 01:10 divine

Codecov Report

Merging #1904 (041d02b) into master (09fcda8) will increase coverage by 0.31%. The diff coverage is 95.55%.

Impacted file tree graph

@@             Coverage Diff              @@
##             master    #1904      +/-   ##
============================================
+ Coverage     86.93%   87.24%   +0.31%     
- Complexity      663      675      +12     
============================================
  Files            33       33              
  Lines          1554     1592      +38     
============================================
+ Hits           1351     1389      +38     
  Misses          203      203              
Impacted Files Coverage Δ Complexity Δ
src/Jenssegers/Mongodb/Connection.php 91.48% <92.00%> (+0.18%) 47.00 <9.00> (+9.00)
src/Jenssegers/Mongodb/Query/Builder.php 89.54% <100.00%> (+0.62%) 165.00 <3.00> (+3.00)
...Jenssegers/Mongodb/MongodbQueueServiceProvider.php 100.00% <0.00%> (+16.66%) 2.00% <0.00%> (ø%)

Continue to review full report at Codecov.

Legend - Click here to learn more Δ = absolute <relative> (impact), ø = not affected, ? = missing data Powered by Codecov. Last update 09fcda8...041d02b. Read the comment docs.

codecov-io avatar Nov 20 '20 07:11 codecov-io

Any update on transactions support?

ymgsmz avatar Jan 26 '21 20:01 ymgsmz

any news?

patie avatar Feb 12 '21 14:02 patie

@klinson copy current ci part . See here

Smolevich avatar Feb 25 '21 06:02 Smolevich

Any news guys? Can you review please @jenssegers ?

josemiguelq avatar Mar 26 '21 20:03 josemiguelq

review please @Smolevich

klinson avatar Mar 27 '21 05:03 klinson

Any updates on this branch being merged, it looks so close to being completed

mattg66 avatar Jul 24 '21 18:07 mattg66

@jenssegers ... when is this package going to support multi-document transactions?

redbonzai avatar Jan 18 '22 12:01 redbonzai

Any status on transactions support? Really appreciate this feature to be there. Thanks

MageloPST avatar Feb 10 '22 16:02 MageloPST

Any update so far?

salvationarinze avatar May 24 '22 21:05 salvationarinze