generated from tailored/router-db-template
72 lines
1.3 KiB
TypeScript
72 lines
1.3 KiB
TypeScript
import { sequelize } from '@/modules/sequelize.ts';
|
|
import { DataTypes, Model } from 'sequelize';
|
|
|
|
export interface AppDemoData {
|
|
[key: string]: any;
|
|
}
|
|
|
|
export type AppDemo = Partial<InstanceType<typeof AppDemoModel>>;
|
|
|
|
export class AppDemoModel extends Model {
|
|
declare id: string;
|
|
declare title: string;
|
|
declare description: string;
|
|
declare summary: string;
|
|
|
|
declare data: AppDemoData;
|
|
declare tags: string[];
|
|
declare version: string;
|
|
|
|
declare uid: string;
|
|
|
|
declare createdAt: Date;
|
|
declare updatedAt: Date;
|
|
}
|
|
|
|
AppDemoModel.init(
|
|
{
|
|
id: {
|
|
type: DataTypes.UUID,
|
|
primaryKey: true,
|
|
defaultValue: DataTypes.UUIDV4,
|
|
},
|
|
title: {
|
|
type: DataTypes.TEXT,
|
|
defaultValue: '',
|
|
},
|
|
description: {
|
|
type: DataTypes.TEXT,
|
|
defaultValue: '',
|
|
},
|
|
summary: {
|
|
type: DataTypes.TEXT,
|
|
defaultValue: '',
|
|
},
|
|
tags: {
|
|
type: DataTypes.JSONB,
|
|
defaultValue: [],
|
|
},
|
|
version: {
|
|
type: DataTypes.INTEGER,
|
|
defaultValue: 0,
|
|
},
|
|
data: {
|
|
type: DataTypes.JSONB,
|
|
defaultValue: {},
|
|
},
|
|
uid: {
|
|
type: DataTypes.UUID,
|
|
allowNull: false,
|
|
},
|
|
},
|
|
{
|
|
sequelize,
|
|
tableName: 'kv_app_demo',
|
|
paranoid: true,
|
|
},
|
|
);
|
|
|
|
AppDemoModel.sync({ alter: true, logging: false }).catch((e) => {
|
|
console.error('AppDemoModel sync', e);
|
|
});
|