Created
May 23, 2020 23:42
-
-
Save EnetoJara/92aee8dfe2933c2ab383512db5c17625 to your computer and use it in GitHub Desktop.
This file contains 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
import { AccountAttributes, Repository } from "@eneto/models"; | |
import { DataTypes, Sequelize } from "sequelize"; | |
/** | |
* Account factory | |
* | |
* @param {import("sequelize").Sequelize} sequelize Sequelize database instance. | |
* @returns {Repository<AccountAttributes>} Instance of Accounts Entity. | |
*/ | |
function AccountFactory(sequelize: Sequelize): Repository<AccountAttributes> { | |
return sequelize.define( | |
"accounts", | |
{ | |
id: { | |
type: DataTypes.BIGINT, | |
allowNull: false, | |
unique: true, | |
primaryKey: true, | |
autoIncrement: true, | |
}, | |
username: { | |
type: DataTypes.STRING, | |
allowNull: false, | |
unique: true, | |
}, | |
psswrd: { | |
type: DataTypes.STRING, | |
allowNull: false, | |
}, | |
createdAt: { | |
type: DataTypes.DATE, | |
allowNull: false, | |
defaultValue: DataTypes.NOW, | |
}, | |
updatedAt: { | |
type: DataTypes.DATE, | |
allowNull: false, | |
defaultValue: DataTypes.NOW, | |
}, | |
}, | |
{ | |
freezeTableName: true, | |
} | |
) as Repository<AccountAttributes>; | |
} | |
export { AccountFactory }; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment