// listed attributes will be 'id' & 'firstName'.
class User extends Model<InferAttributes<User>> {
id: number;
firstName: string;
}
// listed attributes will be 'id' & 'firstName'.
// we're excluding the `name` getter & `projects` attribute using the `omit` option.
class User extends Model<InferAttributes<User, { omit: 'name' | 'projects' }>> {
id: number;
firstName: string;
// this is a getter, not an attribute. It should not be listed in attributes.
get name(): string { return this.firstName; }
// this is an association, it should not be listed in attributes
projects?: Project[];
}
// listed attributes will be 'id' & 'firstName'.
// we're excluding the `name` getter & `test` attribute using the `NonAttribute` branded type.
class User extends Model<InferAttributes<User>> {
id: number;
firstName: string;
// this is a getter, not an attribute. It should not be listed in attributes.
get name(): NonAttribute<string> { return this.firstName; }
// this is an association, it should not be listed in attributes
projects?: NonAttribute<Project[]>;
}
Generated using TypeDoc
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.