-
Notifications
You must be signed in to change notification settings - Fork 10
/
models.go
34 lines (29 loc) · 1.19 KB
/
models.go
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
package index
import (
"time"
)
// Dataset refers to a VectorDB data space.
// @Description Dataset refers to a VectorDB data space.
type Dataset struct {
ID string `gorm:"primaryKey" json:"id"`
EmbedDimension int `json:"embed_dim,omitempty"`
Files []File `gorm:"foreignKey:Dataset;references:ID;constraint:OnDelete:CASCADE;"`
}
type File struct {
ID string `gorm:"primaryKey" json:"id"`
Dataset string `gorm:"primaryKey" json:"dataset"` // Foreign key to Dataset
Documents []Document `gorm:"foreignKey:FileID,Dataset;references:ID,Dataset;constraint:OnDelete:CASCADE;"`
// File metadata, commonly used for deduplication
FileMetadata `json:",inline"`
}
type FileMetadata struct {
Name string `json:"name"`
AbsolutePath string `json:"absolute_path"`
Size int64 `json:"size"`
ModifiedAt time.Time `json:"modified_at"`
}
type Document struct {
ID string `gorm:"primaryKey" json:"id"`
Dataset string `gorm:"primaryKey" json:"dataset"` // Foreign key to Dataset, part of composite primary key with FileID
FileID string `gorm:"primaryKey" json:"file_id"` // Foreign key to File, part of composite primary key with Dataset
}