update new way

This commit is contained in:
2024-11-17 01:35:05 +08:00
parent 7ec8a001de
commit dc69b95f39
13 changed files with 463 additions and 1030 deletions

View File

@@ -1,9 +1,9 @@
import { sequelize } from '../../../modules/sequelize.ts';
import { DataTypes, Model } from 'sequelize';
import crypto from 'crypto';
export interface ContainerData {}
export type ContainerPublish = {
key: string;
key: string;
title?: string;
description?: string;
fileName?: string;
@@ -21,11 +21,20 @@ export class ContainerModel extends Model {
declare type: string;
declare tags: string[];
declare code: string;
declare hash: string;
declare source: string;
declare sourceType: string;
declare data: ContainerData;
declare publish: ContainerPublish;
declare uid: string;
declare updatedAt: Date;
declare createdAt: Date;
createHash() {
const { code } = this;
const hash = crypto.createHash('md5');
hash.update(code);
this.hash = hash.digest('hex');
}
}
ContainerModel.init(
{
@@ -55,6 +64,10 @@ ContainerModel.init(
type: DataTypes.TEXT,
defaultValue: '',
},
hash: {
type: DataTypes.TEXT,
defaultValue: '',
},
source: {
type: DataTypes.STRING,
defaultValue: '',