#1 2019-08-02 17:26:53

marcolanger
Member
Registered: 2019-08-02
Posts: 5

MongoDB transaction

Is possible to use transaction with mormot and mongodb? if it does, how can i do it?

Offline

#2 2019-08-03 16:51:27

ab
Administrator
From: France
Registered: 2010-06-21
Posts: 14,659
Website

Re: MongoDB transaction

Mongo only supports transaction in its latest 4 version.

mORMot doesn't support it yet.

Offline

#3 2019-08-05 10:49:52

marcolanger
Member
Registered: 2019-08-02
Posts: 5

Re: MongoDB transaction

Do you have any predictions of when they will be supported?

Offline

#4 2019-08-05 14:24:01

ab
Administrator
From: France
Registered: 2010-06-21
Posts: 14,659
Website

Re: MongoDB transaction

No plan yet.
But any source code input is welcome!

Note that IMHO transactions are not the way to use a NoSQL database like MongoDB.
You should rather use the "DDD aggregate document" or "denormalizing" concept, i.e. use the document as the boundaries of the transaction.
See our documentation about it.

If you want to use transactions in a way similar to what RDBMS do (i.e. to join writes on several tables) - just use a SQL database.

Offline

#5 2019-08-05 14:34:24

ab
Administrator
From: France
Registered: 2010-06-21
Posts: 14,659
Website

Re: MongoDB transaction

See what Percona states:

If you absolutely need a transaction in your application use it. But don’t use transactions only because they are cool, since in some cases a proper data model based on embedding documents in collections and denormalizing your data could be the best solution. MongoDB isn’t by its nature a relational database; as long as you are able to model your data keeping in mind that it’s a NOSQL database you should avoid using transactions. In specific cases, or if you already have a database with strong “informal relations” between the collections that you cannot change, then you could choose to rely on transactions.

https://www.percona.com/blog/2018/12/04 … nsactions/

I 100% agree with them.

Offline

#6 2019-08-06 14:02:01

marcolanger
Member
Registered: 2019-08-02
Posts: 5

Re: MongoDB transaction

I read all the content and realized that i really don't need to use transactions.

Thank you for your help and patience

Offline

Board footer

Powered by FluxBB