Reformatted the attachment model
This commit is contained in:
parent
dff64b31a4
commit
de220ae02a
@ -1,12 +1,29 @@
|
|||||||
import { Association, BelongsToGetAssociationMixin, BelongsToManyGetAssociationsMixin, CreationOptional, DataTypes, ForeignKey, InferAttributes, InferCreationAttributes, Model, NonAttribute, Sequelize } from "@sequelize/core";
|
import {
|
||||||
import { Post } from "./Post";
|
Association,
|
||||||
|
CreationOptional,
|
||||||
|
DataTypes,
|
||||||
|
ForeignKey,
|
||||||
|
InferAttributes,
|
||||||
|
InferCreationAttributes,
|
||||||
|
Model,
|
||||||
|
NonAttribute
|
||||||
|
} from "@sequelize/core";
|
||||||
|
|
||||||
|
import {
|
||||||
|
Attribute,
|
||||||
|
AutoIncrement,
|
||||||
|
BelongsTo,
|
||||||
|
NotNull,
|
||||||
|
PrimaryKey,
|
||||||
|
Unique
|
||||||
|
} from "@sequelize/core/decorators-legacy";
|
||||||
|
|
||||||
import { SqliteDialect } from '@sequelize/sqlite3';
|
|
||||||
import { Attribute, AutoIncrement, BelongsTo, BelongsToMany, NotNull, PrimaryKey, Unique } from "@sequelize/core/decorators-legacy";
|
|
||||||
import { Bucket } from "./Bucket";
|
import { Bucket } from "./Bucket";
|
||||||
import { UUID } from "crypto";
|
type AttachmentAttributes = InferAttributes<Attachment>;
|
||||||
|
type AttachmentCreationAttributes = InferCreationAttributes<Attachment>;
|
||||||
|
|
||||||
|
export class Attachment extends Model<AttachmentAttributes,AttachmentCreationAttributes> {
|
||||||
|
|
||||||
export class Attachment extends Model<InferAttributes<Attachment>, InferCreationAttributes<Attachment>> {
|
|
||||||
@PrimaryKey
|
@PrimaryKey
|
||||||
@AutoIncrement
|
@AutoIncrement
|
||||||
@Attribute(DataTypes.INTEGER)
|
@Attribute(DataTypes.INTEGER)
|
||||||
@ -14,17 +31,17 @@ export class Attachment extends Model<InferAttributes<Attachment>, InferCreation
|
|||||||
declare id: CreationOptional<number>;
|
declare id: CreationOptional<number>;
|
||||||
@Attribute(DataTypes.STRING)
|
@Attribute(DataTypes.STRING)
|
||||||
declare filename: string
|
declare filename: string
|
||||||
|
|
||||||
// Associations
|
// Associations
|
||||||
@Attribute(DataTypes.UUIDV4)
|
@Attribute(DataTypes.UUIDV4)
|
||||||
@NotNull
|
@NotNull
|
||||||
declare bucket_id: ForeignKey<Bucket['id']>;
|
declare bucket_id: ForeignKey<Bucket['id']>;
|
||||||
|
|
||||||
@BelongsTo(()=>Bucket,{foreignKey: 'bucket_id', inverse: {type: "hasMany", as: 'attachments'}})
|
@BelongsTo(() => Bucket, { foreignKey: 'bucket_id', inverse: { type: "hasMany", as: 'attachments' } })
|
||||||
declare bucket?:NonAttribute<Bucket>;
|
declare bucket?: NonAttribute<Bucket>;
|
||||||
|
|
||||||
declare static associations: {
|
declare static associations: {
|
||||||
bucket: Association<Bucket, Attachment>;
|
bucket: Association<Bucket, Attachment>;
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user