feat(entity): Provide a new API for entities#56199
Conversation
|
Would have preferred the new API and the reference implementation in backup codes and Tagging to be two different commits. But cool. What do you think of a CacheEnabled repository next to it (that wraps the Repository and just has a runtime cache)? Have a mapper with such functionality in tables, and saw it on at least another app as well, might be worth to have something like this implemented once properly? |
Currently it's more of a prototype, I'll split that in multiple commits.
Yes that could make sense. That I also saw in multiple apps is the relation stuff: https://github.com/nextcloud/deck/blob/main/lib/Db/RelationalEntity.php which could be quite handy |
| $this->mapper->insert($tag); | ||
| } catch (Exception $e) { | ||
| if ($e->getReason() !== Exception::REASON_UNIQUE_CONSTRAINT_VIOLATION) { | ||
| $this->logger->error($e->getMessage(), [ | ||
| 'exception' => $e, | ||
| 'app' => 'core', | ||
| ]); |
There was a problem hiding this comment.
Please add an insertIfNotExists method for this in Repository.
There is insertOrUpdate already.
27d1fd8 to
29a9903
Compare
Entity are now simple data object with attributes for the database mapping. They are manipulated via a Repository which reads the attributes to insert, update, delete and queries the PDO from the database. Using attributes makes it easier to extends in the future with relations (ManyToMany, OneToMany, OneToOne, ...). The design of the Repository is based on a mix between the Doctrine ORM repository while keeping some methods from the QBMapper for easier porting. Signed-off-by: Carl Schwan <carl.schwan@nextcloud.com>
And do a lot of refactoring Signed-off-by: Carl Schwan <carlschwan@kde.org>
Signed-off-by: Carl Schwan <carl@carlschwan.eu>
Assisted-by: ClaudeCode:claude-opus-4-8 Signed-off-by: Carl Schwan <carl@carlschwan.eu>
Signed-off-by: Carl Schwan <carl@carlschwan.eu>
29a9903 to
0ac62ed
Compare
0ac62ed to
a2cdc02
Compare
Signed-off-by: Carl Schwan <carl@carlschwan.eu>
This is a left over from the maps prototype Signed-off-by: Carl Schwan <carl@carlschwan.eu>
f362314 to
68c1790
Compare
Entity are now simple data object with attributes for the database mapping. They are manipulated via a Repository which reads the attributes to insert, update, delete and queries the PDO from the database.
Using attributes makes it easier to extends in the future with relations (ManyToMany, OneToMany, OneToOne, ...).
The design of the Repository is based on a mix between the Doctrine ORM repository while keeping some methods from the QBMapper for easier porting.
Example of a entity
Checklist
3. to review, feature component)stable32)