To define mappings between a model and a table, use the `define` method. Sequelize will then automatically add the attributes `createdAt` and `updatedAt` to it. So you will be able to know when the database entry went into the db and when it was updated the last time. If you do not want timestamps on your models, only want some timestamps, or you are working with an existing database where the columns are named something else, jump straight on to [configuration ][0]to see how to do that.
```js
var Project = sequelize.define('Project', {
title: Sequelize.STRING,
description: Sequelize.TEXT
})
var Task = sequelize.define('Task', {
title: Sequelize.STRING,
description: Sequelize.TEXT,
...
...
@@ -17,7 +17,7 @@ var Task = sequelize.define('Task', {
```
You can also set some options on each column:
```js
varFoo=sequelize.define('Foo',{
// instantiating will automatically set the flag to true if not set
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)
```
The BLOB data type allows you to insert data both as strings and as buffers. When you do a find or findAll on a model which has a BLOB column. that data will always be returned as a buffer.
If you are working with the PostgreSQL TIMESTAMP WITHOUT TIME ZONE and you need to parse it to a different timezone, please use the pg library's own parser: