update new way
This commit is contained in:
@@ -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: '',
|
||||
|
||||
Reference in New Issue
Block a user