universo-platform-3d

Форк
0
57 строк · 1.2 Кб
1
import { Prop, Schema, SchemaFactory } from '@nestjs/mongoose'
2
import { ApiProperty } from '@nestjs/swagger'
3
import * as mongoose from 'mongoose'
4
import { Document } from 'mongoose'
5
import { Asset } from '../asset/asset.schema'
6
import { Space } from '../space/space.schema'
7

8
import { User } from '../user/user.schema'
9

10
export type FavoriteDocument = Favorite & Document
11

12
/**
13
 * 2023-05-01 12:54:52 !!This should be refactored to use Mongoose correctly with 1 property instead of a different field for every type of entity
14
  This schema isn't in use yet
15
 */
16

17
@Schema({
18
  timestamps: true,
19
  toJSON: {
20
    virtuals: true
21
  }
22
})
23
export class Favorite {
24
  @Prop({
25
    required: false,
26
    type: mongoose.Schema.Types.ObjectId,
27
    ref: 'Asset'
28
  })
29
  @ApiProperty()
30
  asset: Asset
31

32
  @Prop({
33
    required: false,
34
    type: mongoose.Schema.Types.ObjectId,
35
    ref: 'Space'
36
  })
37
  @ApiProperty()
38
  land: Space
39

40
  @Prop({
41
    required: false,
42
    type: mongoose.Schema.Types.ObjectId,
43
    ref: 'User'
44
  })
45
  @ApiProperty()
46
  user: User
47

48
  @Prop({
49
    required: true,
50
    type: mongoose.Schema.Types.ObjectId,
51
    ref: 'User'
52
  })
53
  @ApiProperty()
54
  creator: User
55
}
56

57
export const FavoriteSchema = SchemaFactory.createForClass(Favorite)
58

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

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

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

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