68 lines
1.5 KiB
TypeScript
68 lines
1.5 KiB
TypeScript
import {
|
|
Entity,
|
|
BeforeInsert,
|
|
DeleteDateColumn,
|
|
CreateDateColumn,
|
|
UpdateDateColumn,
|
|
Column,
|
|
PrimaryColumn,
|
|
} from "typeorm"
|
|
import { ulid } from "ulid"
|
|
|
|
@Entity()
|
|
export class Image {
|
|
@PrimaryColumn()
|
|
id: string
|
|
|
|
@Column()
|
|
url: string
|
|
|
|
@CreateDateColumn({ type: "timestamptz" })
|
|
created_at: Date
|
|
|
|
@UpdateDateColumn({ type: "timestamptz" })
|
|
updated_at: Date
|
|
|
|
@DeleteDateColumn({ type: "timestamptz" })
|
|
deleted_at: Date
|
|
|
|
@Column({ type: "jsonb", nullable: true })
|
|
metadata: any
|
|
|
|
@BeforeInsert()
|
|
private beforeInsert() {
|
|
if (this.id) return
|
|
const id = ulid()
|
|
this.id = `img_${id}`
|
|
}
|
|
}
|
|
|
|
/**
|
|
* @schema image
|
|
* title: "Image"
|
|
* description: "Images holds a reference to a URL at which the image file can be found."
|
|
* x-resourceId: image
|
|
* properties:
|
|
* id:
|
|
* description: "The id of the Image. This value will be prefixed by `img_`."
|
|
* type: string
|
|
* url:
|
|
* description: "The URL at which the image file can be found."
|
|
* type: string
|
|
* created_at:
|
|
* description: "The date with timezone at which the resource was created."
|
|
* type: string
|
|
* format: date-time
|
|
* update_at:
|
|
* description: "The date with timezone at which the resource was last updated."
|
|
* type: string
|
|
* format: date-time
|
|
* deleted_at:
|
|
* description: "The date with timezone at which the resource was deleted."
|
|
* type: string
|
|
* format: date-time
|
|
* metadata:
|
|
* description: "An optional key-value map with additional information."
|
|
* type: object
|
|
*/
|