返回 AiToEarn
media-group.schema.ts
根目录 / project / aitoearn-backend / libs / mongodb / src / schemas / media-group.schema.ts
1 /*
2 * @Author: nevin
3 * @Date: 2024-09-02 14:45:57
4 * @LastEditTime: 2025-02-22 12:37:22
5 * @LastEditors: nevin
6 * @Description: 媒体库 mediaGroup
7 */
8 import { Prop, Schema, SchemaFactory } from '@nestjs/mongoose'
9 import { UserType } from '@yikart/common'
10 import { DEFAULT_SCHEMA_OPTIONS } from '../mongodb.constants'
11 import { MediaType } from './media.schema'
12 import { WithTimestampSchema } from './timestamp.schema'
13
14 @Schema({ ...DEFAULT_SCHEMA_OPTIONS, collection: 'mediaGroup' })
15 export class MediaGroup extends WithTimestampSchema {
16 id: string
17
18 @Prop({
19 required: true,
20 index: true,
21 })
22 userId: string
23
24 @Prop({
25 required: true,
26 index: true,
27 default: UserType.User,
28 })
29 userType: UserType
30
31 @Prop({
32 required: true,
33 enum: MediaType,
34 index: true,
35 })
36 type: MediaType
37
38 @Prop({
39 required: true,
40 })
41 title: string
42
43 @Prop({
44 required: false,
45 })
46 desc?: string
47
48 // 是否默认
49 @Prop({
50 required: true,
51 index: true,
52 default: false,
53 })
54 isDefault: boolean
55 }
56
57 export const MediaGroupSchema = SchemaFactory.createForClass(MediaGroup)
58
58 lines TYPESCRIPT