universo-platform-3d

Форк
0
41 строка · 1.1 Кб
1
import { Prop, Schema, SchemaFactory } from '@nestjs/mongoose'
2
import { ApiProperty } from '@nestjs/swagger'
3
import mongoose from 'mongoose'
4

5
export type UserCartItemDocument = UserCartItem & Document
6

7
/**
8
 * @description Only used for entities that can be purchased. Right now this is is just Asset, but in the future, can be a Space, potentialy a SpaceObject (pending any refactoring), a full Space, a script, etc.
9
 * @date 2023-07-09 16:06
10
 */
11
export enum ENTITY_TYPE_AVAILABLE_TO_PURCHASE {
12
  ASSET = 'ASSET'
13
  // SPACE_OBJECT?
14
}
15

16
@Schema({
17
  timestamps: true,
18
  toJSON: {
19
    virtuals: true
20
  }
21
})
22
export class UserCartItem {
23
  @Prop({
24
    type: mongoose.Types.ObjectId,
25
    refPath: 'entityType',
26
    required: true
27
  })
28
  @ApiProperty({ type: 'string' })
29
  forEntity: mongoose.Types.ObjectId
30

31
  @Prop({
32
    required: true,
33
    enum: ENTITY_TYPE_AVAILABLE_TO_PURCHASE
34
  })
35
  @ApiProperty({ type: 'string' })
36
  entityType: string
37

38
  // we aren't including price here since that should be pulled from the source of truth at the time of purchase (from the Asset)
39
}
40

41
export const UserCartItemSchema = SchemaFactory.createForClass(UserCartItem)
42

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

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

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

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