Skip to content

Instantly share code, notes, and snippets.

@sdepold
Created June 20, 2012 06:36
Show Gist options
  • Save sdepold/2958440 to your computer and use it in GitHub Desktop.
Save sdepold/2958440 to your computer and use it in GitHub Desktop.
"virtual fields" in sequelize
var Sequelize = require('sequelize')
var sequelize = new Sequelize('sequelize_test', 'root')
var Person = sequelize.define('Person', {
firstName: Sequelize.STRING,
lastName: Sequelize.STRING
}, {
instanceMethods: {
getFullName: function() {
return [this.firstName, this.lastName].join(' ')
}
}
})
sequelize.sync().success(function() {
Person
.create({ firstName: 'Sascha', lastName: 'Depold' })
.success(function(sdepold){ console.log(sdepold.getFullName()) })
})
@pdasika82
Copy link

Hello Sascha!

Done. Added https://gist.github.com/2964211 to the pull request.

Thanks,
Pranil

@sdepold
Copy link
Author

sdepold commented Jun 21, 2012 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment