universo-platform-3d
57 строк · 1.2 Кб
1import { Prop, Schema, SchemaFactory } from '@nestjs/mongoose'2import { ApiProperty } from '@nestjs/swagger'3import * as mongoose from 'mongoose'4import { Document } from 'mongoose'5import { Asset } from '../asset/asset.schema'6import { Space } from '../space/space.schema'7
8import { User } from '../user/user.schema'9
10export type FavoriteDocument = Favorite & Document11
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
14This schema isn't in use yet
15*/
16
17@Schema({18timestamps: true,19toJSON: {20virtuals: true21}22})23export class Favorite {24@Prop({25required: false,26type: mongoose.Schema.Types.ObjectId,27ref: 'Asset'28})29@ApiProperty()30asset: Asset31
32@Prop({33required: false,34type: mongoose.Schema.Types.ObjectId,35ref: 'Space'36})37@ApiProperty()38land: Space39
40@Prop({41required: false,42type: mongoose.Schema.Types.ObjectId,43ref: 'User'44})45@ApiProperty()46user: User47
48@Prop({49required: true,50type: mongoose.Schema.Types.ObjectId,51ref: 'User'52})53@ApiProperty()54creator: User55}
56
57export const FavoriteSchema = SchemaFactory.createForClass(Favorite)58