deepkit-framework icon indicating copy to clipboard operation
deepkit-framework copied to clipboard

[Feature] Integrated ORM Plugin API

Open Char2sGu opened this issue 3 years ago • 3 comments

Currently there are actually no "plugin" support in the ORM implementation. The current SoftDelete plugin is just a mix of some other public APIs.

It can be better to have a integrated plugin support, like:

class SoftDeletePlugin implements OrmPlugin {
  ...
}
@entity.name("user").use(new SoftDeletePlugin)
class User {}

Char2sGu avatar Jun 15 '22 08:06 Char2sGu

It should be an API that does not pull backend code, so that models can still be used in frontend (and elsewhere). Thus, it should be a declarative way.

marcj avatar Jun 15 '22 09:06 marcj

Indeed. Then this should be able to work I think:

new Database(new MemoryDatabaseAdapter(), [User], [new SoftDeletePlugin()]);
@entity.data("soft-deletable", true)
class User {}

Char2sGu avatar Jun 15 '22 09:06 Char2sGu

We should not forget interface entities:

interface User extends Entity<>, SoftDeletePlugin {

}

marcj avatar Jun 20 '22 00:06 marcj