universo-platform-3d

Форк
0
63 строки · 1.8 Кб
1
import { Prop, Schema, SchemaFactory } from '@nestjs/mongoose'
2
import { ApiProperty } from '@nestjs/swagger'
3
import mongoose, { Document } from 'mongoose'
4
import { Role, RoleSchema } from '../roles/models/role.schema'
5
import { ISchemaWithRole } from '../roles/role-consumer.interface'
6
import { AssetPublicData } from './asset.schema'
7

8
// Properties must not be undefined so that getPublicPropertiesForMongooseQuery can work
9
export class TexturePublicData extends AssetPublicData {
10
  @ApiProperty()
11
  textureName = ''
12
  @ApiProperty()
13
  textureImageFileHashMD5 = ''
14
  @ApiProperty()
15
  textureLowQualityFileHashMD5 = ''
16
  @ApiProperty()
17
  textureImagePropertyAppliesTo = ''
18
}
19

20
export type TextureDocument = Texture & Document
21

22
@Schema({
23
  timestamps: true,
24
  toJSON: {
25
    virtuals: true
26
  }
27
  // discriminatorKey: __t <- don't uncomment this line: this line is to note that __t is the Mongoose default discriminator key that we use for simplicity rather than specifying our own discriminator key. When this schema is instantiated, __t is "Texture". This is DIFFERENT from assetType since we hadn't been using discriminators up until 2023-02-04 18:49:52. See https://mongoosejs.com/docs/discriminators.html#discriminator-keys. Walkthrough: https://www.loom.com/share/7e09d2777ef94368bcd5fd8c8341b5ef
28
})
29
export class Texture {
30
  _id: string
31
  @Prop({
32
    trim: true
33
  })
34
  @ApiProperty()
35
  textureImageFileHashMD5: string
36

37
  @Prop({
38
    trim: true
39
  })
40
  @ApiProperty()
41
  textureLowQualityFileHashMD5: string
42

43
  @Prop({
44
    trim: true
45
  })
46
  @ApiProperty()
47
  textureImagePropertyAppliesTo: string
48

49
  /**
50
   * START Section: ISchemaWithRole implementer
51
   */
52
  @Prop({
53
    required: true,
54
    type: RoleSchema
55
  })
56
  @ApiProperty()
57
  role: Role
58
  /**
59
   * END Section: ISchemaWithRole implementer
60
   */
61
}
62

63
export const TextureSchema = SchemaFactory.createForClass(Texture)
64

Использование cookies

Мы используем файлы cookie в соответствии с Политикой конфиденциальности и Политикой использования cookies.

Нажимая кнопку «Принимаю», Вы даете АО «СберТех» согласие на обработку Ваших персональных данных в целях совершенствования нашего веб-сайта и Сервиса GitVerse, а также повышения удобства их использования.

Запретить использование cookies Вы можете самостоятельно в настройках Вашего браузера.