80 lines
1.6 KiB
TypeScript
80 lines
1.6 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 type Container = {
|
|
id?: string;
|
|
title?: string;
|
|
description?: string;
|
|
type?: string;
|
|
code?: string;
|
|
source?: string;
|
|
sourceType?: string;
|
|
data?: ContainerData;
|
|
};
|
|
export class ContainerModel extends Model {
|
|
declare id: string;
|
|
declare title: string;
|
|
declare description: string;
|
|
declare type: string;
|
|
declare code: string;
|
|
declare source: string;
|
|
declare sourceType: 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.TEXT,
|
|
defaultValue: '',
|
|
},
|
|
source: {
|
|
type: DataTypes.STRING,
|
|
defaultValue: '',
|
|
},
|
|
sourceType: {
|
|
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);
|
|
});
|