type-keystonejs
v0.0.7
Published
Models definition for KeystoneJS using TypeScript classes
Downloads
1
Readme
Type KeystoneJS
This package intends to implement Typescript decorators to create KeystoneJS lists.
This package is working with the V5 of KeystoneJS only.
Motivations
I'm used to work with TypeORM and Typegoose with Typescript. The main goal of these packages is to merge the model declaration and the TS interface into one class only.
When I switched to TS with KeystoneJS V5, I had to create both the Keystone list and the TS interface.
My main goal is to provide a way to create the list and the interface with the same code.
Documentation
@ModelAccess(TeamAccess)
@ModelPlugin(atTracking())
@Model()
export class Team extends EntityModel {
@TextField()
name: string;
@RelationField(() => MediaFile)
picture: MediaFile;
@VirtualField(TeamTotalPoints)
totalPoints: number;
@VirtualField(TeamTotalPointsDifferential)
totalPointsDifferential: { previous: number, current: number };
@RelationField(() => User, { path: 'team', many: true })
users: User[];
@RelationField(() => Company, { path: 'teams' })
company: Company;
}
register(Team);