Shorthand and complete attribute definition
Shorthand attribute definition
const User = attributes({
name: String,
brithday: Date,
})(
class User {
generateRandomBook() {
return '...';
}
}
);Complete attribute definition
const User = attributes({
name: {
type: String,
default: 'Anonymous',
},
cars: {
type: Array,
itemType: String,
default: ['Golf', 'Polo'],
},
book: {
type: String,
default: (instance) => instance.generateRandomBook(),
},
})(
class User {
generateRandomBook() {
return '...';
}
}
);default
itemType
Type concept
Last updated