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

[Feature Suggestion] "version" special Type

Open rogrdat opened this issue 3 years ago • 1 comments

I should be able to describe a property as type version in which case the ORM will auto-increment the property on every DB write starting with 1.

rogrdat avatar Jun 14 '22 01:06 rogrdat

You can do this yourself by subscribing to database events. You would want to subscribe to the onPatchPre query event and the onUpdatePre unit of work event.

You can create your own type type Version = number & Data<'version', true> and then use the reflection API to autoincrement columns with that type.

Then you can use it like this

interface BlogPost {
    title: string;
    createDate: Date;
    updateDate: Date;
    version: Version = 1;
}

timvandam avatar Jun 14 '22 07:06 timvandam