Getter not working #16627
Getter not working
#16627
Replies: 1 comment
-
I figured what the problem was, apparently passing the option "raw" in the "findOne({raw: true})" query was the reason it did not work. |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I have been trying to use the get function in my model, but it's not been working. Although the setter works
name: {
type: DataTypes.STRING,
allowNull: false,
get() {
const value = this.getDataValue("name");
return "@" + value ;
},
set: function (value) {
this.setDataValue("name", value + "yo");
},
},
const user = await User.findOne({ raw: true });
console.log(user.name) // It displays just the name without the "@"
Beta Was this translation helpful? Give feedback.
All reactions