Skip to content

Overriding toJSON instance method #777

@oktapodia

Description

@oktapodia

Versions

  • sequelize: 5.21.7
  • sequelize-typescript: 1.1.0
  • typescript: 3.8.3

I'm submitting a ...

[ ] bug report
[x] feature request

Actual behavior:

Overriding the instance method toJSON is possible in sequelize, not with sequelize-typescript

Expected behavior:

Possibility to override the toJSON instance method

Steps to reproduce:

Related code:

export class Test extends Model<Test> {
	@Column
    name: string;

    @Column
    shouldBeHidden: string;

    toJSON() {
        const values = Object.assign({}, this.get());
        delete values.shouldBeHidden;
        return values;
    }
} 

//returns when serialized
//{ "name": "foo" }

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