Added Sequelize based models
This commit is contained in:
@@ -0,0 +1,38 @@
|
||||
import { Sequelize, DataTypes, Optional, Model, UUIDV4 } from 'sequelize';
|
||||
const sequelize = new Sequelize({
|
||||
dialect: 'sqlite',
|
||||
storage: 'db.sqlite'
|
||||
});
|
||||
interface AuthAttributes{
|
||||
id: number;
|
||||
token: string;
|
||||
user_id: number;
|
||||
};
|
||||
interface AuthCreationAttributes extends Optional<Optional<AuthAttributes, 'id'>,'token'> {};
|
||||
class AuthModel extends Model<AuthAttributes, AuthCreationAttributes>{
|
||||
createdAt?: Date;
|
||||
updatedAt?: Date;
|
||||
token: any;
|
||||
// declare title
|
||||
}
|
||||
export const MAuth = sequelize.define<AuthModel>(
|
||||
'Auth',
|
||||
{
|
||||
id: {
|
||||
allowNull: false,
|
||||
autoIncrement: true,
|
||||
type: DataTypes.INTEGER,
|
||||
primaryKey: true,
|
||||
unique: true,
|
||||
},
|
||||
token: {
|
||||
type: DataTypes.UUID,
|
||||
defaultValue: UUIDV4
|
||||
},
|
||||
user_id: {
|
||||
type: DataTypes.INTEGER,
|
||||
key: "User"
|
||||
}
|
||||
// date: DataTypes.DATE,
|
||||
}
|
||||
);
|
||||
Reference in New Issue
Block a user