pseudo properties
Would be properties that, from the perspective of the user seems like regular properties of the object, but do not exist in the database. Take for example a user object that has first names and last name fields. You could then create a fullname setter:
var foo = sequelize.define('foo', {
..
}, {
getterMethods: {
fullName: function () {
return this.getDataValue('firstName') + ' ' + this.getDataValue('lastName')
}
},
setterMethods: {
fullName: function (value) {
var parts = value.split(' ')
this.setDataValue('lastName', parts[parts.length-1])
this.setDataValue('firstName', parts[0]) // this of course does not work if the user has several first names
}
}
})
When you have a user object you can simply do
console.log(user.fullName)
To see the user's full name. The getter is then being invoked behind the scenes.
Similarily, if you define a setter method for full name you could do
user.fullName = 'John Doe'
Which would then split the passed string into two parts and save them in first and last name. (see the simplified example above)
Protect properties
@ahiipsa already provided a good example of this. Getters are called when you do user.toJSON(), so you can use getters to easily remove sensitive data before sending it to the user.