-
Notifications
You must be signed in to change notification settings - Fork 45
Expand file tree
/
Copy pathTrainingDataset.model.ts
More file actions
87 lines (83 loc) · 1.86 KB
/
TrainingDataset.model.ts
File metadata and controls
87 lines (83 loc) · 1.86 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
import { Schema, Document, Types, model } from 'mongoose'
export interface ITrainingDataset extends Document {
userId: Types.ObjectId
name: string
description?: string
fileName: string
fileType: 'csv' | 'json' | 'markdown' | 'text'
fileSize: number // in bytes
sampleCount: number
status: 'pending' | 'processing' | 'completed' | 'failed'
errorMessage?: string
importedAt?: Date
isActive: boolean
metadata?: {
headers?: string[]
delimiter?: string
encoding?: string
}
createdAt: Date
updatedAt: Date
}
const TrainingDatasetSchema = new Schema<ITrainingDataset>(
{
userId: {
type: Schema.Types.ObjectId,
ref: 'User',
required: true,
},
name: {
type: String,
required: true,
maxlength: 255,
},
description: {
type: String,
maxlength: 1000,
},
fileName: {
type: String,
required: true,
index: true,
},
fileType: {
type: String,
enum: ['csv', 'json', 'markdown', 'text'],
required: true,
},
fileSize: {
type: Number,
required: true,
},
sampleCount: {
type: Number,
default: 0,
},
status: {
type: String,
enum: ['pending', 'processing', 'completed', 'failed'],
default: 'pending',
index: true,
},
errorMessage: String,
importedAt: Date,
isActive: {
type: Boolean,
default: true,
index: true,
},
metadata: {
headers: [String],
delimiter: String,
encoding: String,
},
},
{
timestamps: true,
}
)
// Compound indices for common queries
TrainingDatasetSchema.index({ userId: 1, status: 1 })
TrainingDatasetSchema.index({ userId: 1, isActive: 1 })
TrainingDatasetSchema.index({ userId: 1, createdAt: -1 })
export const TrainingDataset = model<ITrainingDataset>('TrainingDataset', TrainingDatasetSchema)