Sequelize.DATE// DATETIME for mysql / sqlite, TIMESTAMP WITH TIME ZONE for postgres
Sequelize.BOOLEAN// TINYINT(1)
Sequelize.ENUM('value 1','value 2')// An ENUM with allowed values 'value 1' and 'value 2'
Sequelize.ARRAY(Sequelize.TEXT)// Defines an array. PostgreSQL only.
Sequelize.BLOB// BLOB (bytea for PostgreSQL)
Sequelize.BLOB('tiny')// TINYBLOB (bytea for PostgreSQL. Other options are medium and long)
Sequelize.UUID// UUID datatype for PostgreSQL and SQLite, CHAR(36) BINARY for MySQL (use defaultValue: Sequelize.UUIDV1 or Sequelize.UUIDV4 to make sequelize generate the ids automatically)
...
...
@@ -134,22 +134,30 @@ Getters and Setters can be defined in 2 ways (you can mix and match these 2
### Defining as part of a property
```js
varFoo=sequelize.define('Foo',{
name:Sequelize.STRING,
title:{
varEmployee=sequelize.define('Employee',{
name:{
type:Sequelize.STRING,
allowNull:false,
get:function(){
/*
do your magic here and return something!
'this' allows you to access attributes of the model.
example: this.getDataValue('name') works
*/
vartitle=this.getDataValue('title');// 'this' allows you to access attributes of the instance
returnthis.getDataValue('name')+' ('+title+')';
},
},
set:function(v){/* do your magic with the input here! */}