Shorthand and complete type descriptor
Shorthand type descriptor
const User = attributes({
name: String,
brithday: Date
})(class User {
generateRandomBook() {
return '...';
}
});Complete type descriptor
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