Nullable attributes
Nullability and default option
default optionconst User = attributes({
name: {
// automatically non-nullable
type: String,
default: 'Some string',
},
nickname: {
type: String,
nullable: false,
default: 'Some other string',
},
})(class User {});
const userA = new User({ name: null, nickname: null });
userA.attributes; // { name: 'Some string', nickname: null }
const userB = new User({ name: null, nickname: undefined });
userB.attributes; // { name: 'Some string', nickname: 'Some other string' }Coercion
Nullable optional attributes
Nullable required attributes
Nullability and serialization
Last updated