Created
September 17, 2014 17:48
-
-
Save mathisonian/bc551d519b3b90f99778 to your computer and use it in GitHub Desktop.
mimicking an array data type with sequelize.js
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var MyModel = sequelize.define('MyModel', { | |
myArrayField: { | |
type: DataTypes.STRING, | |
get: function() { | |
return JSON.parse(this.getDataValue('myArrayField')); | |
}, | |
set: function(val) { | |
return this.setDataValue('myArrayField', JSON.stringify(val)); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment