angel-dart-archive / orm

moved to angel-dart/angel/packages/orm

Home Page:https://github.com/angel-dart/angel/tree/master/packages/orm

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Support transactions

omarbelkhodja opened this issue · comments

In some frameworks, like Spring/Java, it is possible to specify that all the database operations are executed in the same transaction, simply by adding the @transactional annotation to any method.

I would be interesting to have this feature in Angel also.

As it is right now, QueryExecutor already has a transaction method. In addition, relations are performed through joins, and therefore are all fetched with just one query.

await executor.transaction((tx) async {
  await query1.getOne(tx);
  await query2.delete(tx);
});

I am hesitant to add new annotations, because they tend to bring "magic," all while making things more complex, harder to maintain, and harder to debug. This was one thing I really disliked about Spring - annotation soup, and a lack of clear flow.

I'm going to close this, as transactions are already supported. Do let me know, though, if this is inadequate, and we can reopen this and make changes.

@thosakwe Why is there no documentation on using transaction?

It can be found in the dartdocs, and is visible on the QueryExecutor interface.

Should it be in the README?