universo-platform-3d
41 строка · 1.1 Кб
1import { Prop, Schema, SchemaFactory } from '@nestjs/mongoose'
2import { ApiProperty } from '@nestjs/swagger'
3import mongoose from 'mongoose'
4
5export 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*/
11export enum ENTITY_TYPE_AVAILABLE_TO_PURCHASE {
12ASSET = 'ASSET'
13// SPACE_OBJECT?
14}
15
16@Schema({
17timestamps: true,
18toJSON: {
19virtuals: true
20}
21})
22export class UserCartItem {
23@Prop({
24type: mongoose.Types.ObjectId,
25refPath: 'entityType',
26required: true
27})
28@ApiProperty({ type: 'string' })
29forEntity: mongoose.Types.ObjectId
30
31@Prop({
32required: true,
33enum: ENTITY_TYPE_AVAILABLE_TO_PURCHASE
34})
35@ApiProperty({ type: 'string' })
36entityType: 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
41export const UserCartItemSchema = SchemaFactory.createForClass(UserCartItem)
42