fipamo/brain/models/User.js

56 lines
1.7 KiB
JavaScript

module.exports = function (sequelize, DataTypes) {
var User = sequelize.define('User', {
avatar: {
type: DataTypes.STRING,
unique: false,
allowNull: true
},
handle: {
type: DataTypes.STRING,
unique: true,
allowNull: true
},
email: {
type: DataTypes.STRING,
unique: false,
allowNull: true
},
role: {
type: DataTypes.STRING,
unique: false,
allowNull: true
},
password: {
type: DataTypes.STRING,
unique: true,
allowNull: false
}
}, {
timestamps: true,
// don't delete database entries but set the newly added attribute deletedAt
// to the current date (when deletion was done). paranoid will only work if
// timestamps are enabled
paranoid: true,
// don't use camelcase for automatically added attributes but underscore style
// so updatedAt will be updated_at
underscored: true,
// disable the modification of table names; By default, sequelize will automatically
// transform all passed model names (first parameter of define) into plural.
// if you don't want that, set the following
freezeTableName: false,
// define the table's name
tableName: 'Users',
// Enable optimistic locking. When enabled, sequelize will add a version count attriubte
// to the model and throw an OptimisticLockingError error when stale instances are saved.
// Set to true or a string with the attribute name you want to use to enable.
version: true
});
return User;
};