type-keystonejs
TypeScript icon, indicating that this package has built-in type declarations

0.0.7 • Public • Published

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);

Readme

Keywords

none

Package Sidebar

Install

npm i type-keystonejs

Weekly Downloads

1

Version

0.0.7

License

MIT

Unpacked Size

118 kB

Total Files

81

Last publish

Collaborators

  • aleygues