It cannot detect whether something is a getter or not, you should use the Excluded
parameter to exclude getter & setters from the attribute list.
Example
// listed attributes will be 'id' & 'firstName'. classUserextendsModel<InferAttributes<User>> { id: number; firstName: string; }
Example
// listed attributes will be 'id' & 'firstName'. // we're excluding the `name` getter & `projects` attribute using the `omit` option. classUserextendsModel<InferAttributes<User, { omit: 'name' | 'projects' }>> { id: number; firstName: string;
// this is a getter, not an attribute. It should not be listed in attributes. getname(): string { returnthis.firstName; } // this is an association, it should not be listed in attributes projects?: Project[]; }
Example
// listed attributes will be 'id' & 'firstName'. // we're excluding the `name` getter & `test` attribute using the `NonAttribute` branded type. classUserextendsModel<InferAttributes<User>> { id: number; firstName: string;
// this is a getter, not an attribute. It should not be listed in attributes. getname(): NonAttribute<string> { returnthis.firstName; } // this is an association, it should not be listed in attributes projects?: NonAttribute<Project[]>; }
Utility type to extract Attributes of a given Model class.
It returns all instance properties defined in the Model, except:
It cannot detect whether something is a getter or not, you should use the
Excluded
parameter to exclude getter & setters from the attribute list.Example
Example
Example