Skip to content

Mutators are only working on direct prop access #84

@Novivy

Description

@Novivy
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?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions