返回 AiToEarn
account.schema.ts
根目录 / project / aitoearn-backend / libs / mongodb / src / schemas / account.schema.ts
1 import { Prop, Schema, SchemaFactory } from '@nestjs/mongoose'
2 import { AccountType } from '@yikart/common'
3 import { Schema as MongooseSchema } from 'mongoose'
4
5 import { DEFAULT_SCHEMA_OPTIONS } from '../mongodb.constants'
6 import { WithTimestampSchema } from './timestamp.schema'
7
8 export enum AccountStatus {
9 NORMAL = 1,
10 ABNORMAL = 0,
11 }
12
13 export enum ClientType {
14 WEB = 'web',
15 APP = 'app',
16 }
17
18 @Schema({ ...DEFAULT_SCHEMA_OPTIONS, collection: 'account' })
19 export class Account extends WithTimestampSchema {
20 @Prop({ type: MongooseSchema.Types.String })
21 _id: string
22
23 id: string
24
25 @Prop({
26 required: true,
27 type: String,
28 index: true,
29 default: '',
30 })
31 userId: string
32
33 @Prop({
34 required: true,
35 enum: AccountType,
36 index: true,
37 })
38 type: AccountType
39
40 @Prop({
41 required: true,
42 index: true,
43 })
44 uid: string
45
46 @Prop({
47 required: false,
48 index: true,
49 })
50 account: string
51
52 @Prop({
53 required: false,
54 type: Date,
55 index: true,
56 })
57 loginTime?: Date
58
59 @Prop({
60 required: false,
61 })
62 avatar?: string
63
64 @Prop({
65 required: true,
66 })
67 nickname: string
68
69 @Prop({
70 required: false,
71 enum: ClientType,
72 })
73 clientType?: ClientType
74
75 @Prop({
76 required: false,
77 type: String,
78 })
79 loginCookie: string
80
81 @Prop({
82 required: false,
83 type: String,
84 })
85 access_token: string
86
87 @Prop({
88 required: false,
89 type: String,
90 })
91 refresh_token: string
92
93 @Prop({
94 required: false,
95 type: String,
96 default: '',
97 })
98 token: string
99
100 @Prop({
101 required: true,
102 default: 0,
103 })
104 fansCount: number
105
106 @Prop({
107 required: true,
108 default: 0,
109 })
110 followingCount: number
111
112 @Prop({
113 required: true,
114 default: 0,
115 })
116 readCount: number
117
118 @Prop({
119 required: true,
120 default: 0,
121 })
122 likeCount: number
123
124 @Prop({
125 required: true,
126 default: 0,
127 })
128 collectCount: number
129
130 @Prop({
131 required: true,
132 default: 0,
133 })
134 forwardCount: number
135
136 @Prop({
137 required: true,
138 default: 0,
139 })
140 commentCount: number
141
142 @Prop({
143 required: false,
144 type: Date,
145 })
146 lastStatsTime?: Date
147
148 @Prop({
149 required: true,
150 default: 0,
151 })
152 workCount: number
153
154 @Prop({
155 required: true,
156 default: 0,
157 })
158 income: number
159
160 @Prop({ type: String, required: true })
161 groupId: string
162
163 @Prop({
164 required: true,
165 default: AccountStatus.NORMAL,
166 index: true,
167 })
168 status: AccountStatus
169
170 @Prop({
171 required: true,
172 type: Number,
173 default: 1,
174 })
175 rank: number
176
177 @Prop({ type: String, default: null })
178 relayAccountRef: string | null
179 }
180
181 export const AccountSchema = SchemaFactory.createForClass(Account)
182 AccountSchema.index(
183 { type: 1, uid: 1, account: 1 },
184 {
185 unique: true,
186 name: 'type_1_uid_1_account_1',
187 },
188 )
189
189 lines TYPESCRIPT