65 lines
1.3 KiB
TypeScript

import { sequelize } from '../../../modules/sequelize.ts';
import { DataTypes, Model } from 'sequelize';
export interface ContainerData {
style?: { [key: string]: string };
className?: string;
showChild?: boolean;
shadowRoot?: boolean;
}
export class ContainerModel extends Model {
declare id: string;
declare title: string;
declare description: string;
declare type: string;
declare code: string;
declare source: string;
declare data: ContainerData;
}
ContainerModel.init(
{
id: {
type: DataTypes.UUID,
primaryKey: true,
defaultValue: DataTypes.UUIDV4,
comment: 'id',
},
title: {
type: DataTypes.STRING,
defaultValue: '',
},
description: {
type: DataTypes.STRING,
defaultValue: '',
},
type: {
type: DataTypes.STRING,
defaultValue: '',
},
code: {
type: DataTypes.STRING,
defaultValue: '',
},
source: {
type: DataTypes.STRING,
defaultValue: '',
},
data: {
type: DataTypes.JSON,
defaultValue: {},
},
uid: {
type: DataTypes.UUID,
allowNull: true,
},
},
{
sequelize,
tableName: 'kv_container',
},
);
ContainerModel.sync({ alter: true, logging: false }).catch((e) => {
console.error('ContainerModel sync', e);
});