返回 AiToEarn
tracing.schema.ts
根目录 / project / aitoearn-electron / server / src / db / schema / tracing.schema.ts
1 /*
2 * @Author: nevin
3 * @Date: 2025-02-18 22:32:02
4 * @LastEditTime: 2025-03-04 15:23:22
5 * @LastEditors: nevin
6 * @Description: 跟踪
7 */
8 import { Prop, Schema, SchemaFactory } from '@nestjs/mongoose';
9 import { SchemaTypes } from 'mongoose';
10 import { TimeTemp } from './time.tamp';
11
12 export enum TracingType {
13 EVENT = 'event', // 事件
14 ERROR = 'error', // 错误收集
15 }
16
17 @Schema({
18 collection: 'tracing',
19 versionKey: false,
20 toJSON: { virtuals: true },
21 toObject: { virtuals: true },
22 timestamps: false,
23 })
24 export class Tracing extends TimeTemp {
25 id: string;
26
27 @Prop({
28 required: true,
29 type: String,
30 index: true,
31 })
32 userId: string;
33
34 @Prop({
35 required: true,
36 enum: TracingType,
37 })
38 type: TracingType;
39
40 @Prop({
41 required: true,
42 type: String,
43 index: true,
44 })
45 tag: string;
46
47 @Prop({
48 required: false,
49 type: Number,
50 })
51 accountId?: number; // 平台账号ID
52
53 @Prop({
54 required: false,
55 })
56 desc?: string;
57
58 @Prop({
59 required: false,
60 })
61 dataId?: string; // 关联数据id
62
63 @Prop({
64 required: false,
65 type: SchemaTypes.Mixed,
66 })
67 data?: any; // 支持任意类型
68 }
69
70 export const TracingSchema = SchemaFactory.createForClass(Tracing);
71
71 lines TYPESCRIPT