#1 2023-04-20 03:34:36

zhangguichao
Member
Registered: 2023-03-21
Posts: 29

with mormot+sqlite can i set Isolation level ?

with  mormot+sqlite  can i set  Isolation level ?
for Some concurrent modification operations...

Offline

#2 2023-04-20 06:25:42

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

Re: with mormot+sqlite can i set Isolation level ?

I think the reference is https://www.sqlite.org/isolation.html

In mORMot, we have a single connection to the DB (in the most simple case), protected by a global thread lock in mORMot code.
So the transactions are always serializable, and changes won't appear before the COMMIT.

See also https://www.sqlite.org/lang_transaction.html

Offline

#3 2023-04-20 06:39:47

zhangguichao
Member
Registered: 2023-03-21
Posts: 29

Re: with mormot+sqlite can i set Isolation level ?

I see, thanks。:)

Offline

#4 2023-04-20 06:54:12

zhangguichao
Member
Registered: 2023-03-21
Posts: 29

Re: with mormot+sqlite can i set Isolation level ?

In this case, do I have to use transactions?

(for Some concurrent modification operations...)

Last edited by zhangguichao (2023-04-20 06:54:47)

Offline

#5 2023-04-20 07:59:05

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

Re: with mormot+sqlite can i set Isolation level ?

There are several ways of doing transactions in mORMot:

1) The main pattern in mORMot is to use a TRestBatch, which would create the transaction when making the writes.

2) But you can have transacations at REST level if you want to make nested reads and writes.
This transaction would better be very small in time, because they will block other transactions in the mORMot kernel (not the SQLIte3 kernel).

3) If you really need business-level transactions (e.g. long standing transactions), don't use SQlite3 but another database, and direct SQL to it (via mormot.db.sql classes), all encapsulated behind an interface.

The main points to understand, coming from RDBMS, are
a) That mORMot has to work with no-SQL database backends, with no transaction support. Its ORM is not a full mapping of the RDBMS logic.
b) mORMot favors the "aggregate" repository pattern, where you usually don't need transaction outside of the aggregate object scope - which may be a single row in a SQlite3 database, thanks to array and TDocVariant fields (storing nested info as JSON in the DB).
c) The mORMot 1 documentation is still accurate about these patterns. https://synopse.info/files/html/Synopse … l#TITL_124
d) If you want something more SQL-oriented, just use SQL, over  an interface based service.

Offline

#6 2023-04-20 08:13:56

zhangguichao
Member
Registered: 2023-03-21
Posts: 29

Re: with mormot+sqlite can i set Isolation level ?

Very clear, much appreciated. wink

Offline

Board footer

Powered by FluxBB