export class User extends Model {
static table = 'users';
static primaryKey = 'id';
attributeUsername() {
return Attribute.make({
get: (value) => 'test-username-overwrite',
});
}
}
const user = await User.query().find(1);
res.json(user.username); //output: "test-username-overwrite"
res.json(user); //output: {id:1, username: "John"}
res.json(user.toData()); //output: {id:1, username: "John"}
I don't know if it's intended but what I was excepting is the mutator to apply everywhere
Does there is any other way to disable the auto cast on created_at/updated_at?
I don't know if it's intended but what I was excepting is the mutator to apply everywhere
Does there is any other way to disable the auto cast on
created_at/updated_at?