universo-platform-3d
120 строк · 2.5 Кб
1import { Prop, Schema, SchemaFactory } from '@nestjs/mongoose'2import { ApiProperty } from '@nestjs/swagger'3import * as mongoose from 'mongoose'4import { Document } from 'mongoose'5import { User, UserPublicData } from '../user/user.schema'6
7// Properties must not be undefined so that getPublicPropertiesForMongooseQuery can work
8export class UserGroupPublicData {9@ApiProperty() // @ApiProperty must be included to be exposed by the API and flow to FE codegen10_id = '' // Must not be undefined11@ApiProperty()12createdAt = new Date()13@ApiProperty()14updatedAt = new Date()15@ApiProperty()16name = ''17@ApiProperty()18public = true19@ApiProperty()20discordUrl = ''21@ApiProperty()22ethereumDaoContractPublicKey = ''23@ApiProperty()24polygonDaoContractPublicKey = ''25@ApiProperty({26type: () => UserPublicData27})28owners = [new UserPublicData()]29@ApiProperty()30image = ''31
32@ApiProperty()33publicDescription = ''34
35@ApiProperty()36twitterUrl = ''37
38@ApiProperty()39websiteUrl = ''40}
41
42export type UserGroupDocument = UserGroup & Document43
44@Schema({45timestamps: true,46toJSON: {47virtuals: true48}49})50export class UserGroup {51@ApiProperty()52_id: string53@ApiProperty()54createdAt: Date // this is managed by mongoose timestamps: true, but defining it here so types will align55@ApiProperty()56updatedAt: Date // this is managed by mongoose timestamps: true, but defining it here so types will align57
58@Prop()59@ApiProperty()60name: string61
62@Prop({63default: true64})65@ApiProperty()66public: string67
68@Prop()69@ApiProperty()70discordUrl: string71
72@Prop()73@ApiProperty()74ethereumDaoContractPublicKey: string75
76@Prop()77@ApiProperty()78polygonDaoContractPublicKey: string79
80@Prop({ type: [mongoose.Schema.Types.ObjectId], ref: 'User' })81@ApiProperty()82moderators: User[]83
84@Prop({ type: [mongoose.Schema.Types.ObjectId], ref: 'User' })85@ApiProperty()86owners: User[]87
88@Prop({89required: true90})91@Prop({ type: mongoose.Schema.Types.ObjectId, ref: 'User' })92@ApiProperty()93primaryContact: User94
95@Prop()96@ApiProperty()97image: string // url98
99@Prop()100@ApiProperty()101publicDescription: string102
103@Prop()104@ApiProperty()105twitterUrl: string106
107@Prop({ type: [mongoose.Schema.Types.ObjectId], ref: 'User' })108@ApiProperty()109users: User[]110
111@Prop()112@ApiProperty()113websiteUrl: string114
115@Prop({ type: mongoose.Schema.Types.ObjectId, ref: 'User', required: true })116@ApiProperty()117creator: User118}
119
120export const UserGroupSchema = SchemaFactory.createForClass(UserGroup)121