universo-platform-3d

Форк
0
120 строк · 2.5 Кб
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 { User, UserPublicData } from '../user/user.schema'
6

7
// Properties must not be undefined so that getPublicPropertiesForMongooseQuery can work
8
export class UserGroupPublicData {
9
  @ApiProperty() // @ApiProperty must be included to be exposed by the API and flow to FE codegen
10
  _id = '' // Must not be undefined
11
  @ApiProperty()
12
  createdAt = new Date()
13
  @ApiProperty()
14
  updatedAt = new Date()
15
  @ApiProperty()
16
  name = ''
17
  @ApiProperty()
18
  public = true
19
  @ApiProperty()
20
  discordUrl = ''
21
  @ApiProperty()
22
  ethereumDaoContractPublicKey = ''
23
  @ApiProperty()
24
  polygonDaoContractPublicKey = ''
25
  @ApiProperty({
26
    type: () => UserPublicData
27
  })
28
  owners = [new UserPublicData()]
29
  @ApiProperty()
30
  image = ''
31

32
  @ApiProperty()
33
  publicDescription = ''
34

35
  @ApiProperty()
36
  twitterUrl = ''
37

38
  @ApiProperty()
39
  websiteUrl = ''
40
}
41

42
export type UserGroupDocument = UserGroup & Document
43

44
@Schema({
45
  timestamps: true,
46
  toJSON: {
47
    virtuals: true
48
  }
49
})
50
export class UserGroup {
51
  @ApiProperty()
52
  _id: string
53
  @ApiProperty()
54
  createdAt: Date // this is managed by mongoose timestamps: true, but defining it here so types will align
55
  @ApiProperty()
56
  updatedAt: Date // this is managed by mongoose timestamps: true, but defining it here so types will align
57

58
  @Prop()
59
  @ApiProperty()
60
  name: string
61

62
  @Prop({
63
    default: true
64
  })
65
  @ApiProperty()
66
  public: string
67

68
  @Prop()
69
  @ApiProperty()
70
  discordUrl: string
71

72
  @Prop()
73
  @ApiProperty()
74
  ethereumDaoContractPublicKey: string
75

76
  @Prop()
77
  @ApiProperty()
78
  polygonDaoContractPublicKey: string
79

80
  @Prop({ type: [mongoose.Schema.Types.ObjectId], ref: 'User' })
81
  @ApiProperty()
82
  moderators: User[]
83

84
  @Prop({ type: [mongoose.Schema.Types.ObjectId], ref: 'User' })
85
  @ApiProperty()
86
  owners: User[]
87

88
  @Prop({
89
    required: true
90
  })
91
  @Prop({ type: mongoose.Schema.Types.ObjectId, ref: 'User' })
92
  @ApiProperty()
93
  primaryContact: User
94

95
  @Prop()
96
  @ApiProperty()
97
  image: string // url
98

99
  @Prop()
100
  @ApiProperty()
101
  publicDescription: string
102

103
  @Prop()
104
  @ApiProperty()
105
  twitterUrl: string
106

107
  @Prop({ type: [mongoose.Schema.Types.ObjectId], ref: 'User' })
108
  @ApiProperty()
109
  users: User[]
110

111
  @Prop()
112
  @ApiProperty()
113
  websiteUrl: string
114

115
  @Prop({ type: mongoose.Schema.Types.ObjectId, ref: 'User', required: true })
116
  @ApiProperty()
117
  creator: User
118
}
119

120
export const UserGroupSchema = SchemaFactory.createForClass(UserGroup)
121

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

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

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

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