Documentation
¶
Overview ¶
Package models implements all PocketBase DB models and DTOs.
Index ¶
- Constants
- type ApiKey
- type BaseModel
- func (m *BaseModel) GetCreated() types.DateTime
- func (m *BaseModel) GetId() string
- func (m *BaseModel) GetUpdated() types.DateTime
- func (m *BaseModel) HasId() bool
- func (m *BaseModel) IsNew() bool
- func (m *BaseModel) MarkAsNew()
- func (m *BaseModel) MarkAsNotNew()
- func (m *BaseModel) PostScan() error
- func (m *BaseModel) RefreshCreated()
- func (m *BaseModel) RefreshId()
- func (m *BaseModel) RefreshUpdated()
- func (m *BaseModel) SetId(id string)
- type BrowserProfile
- type BrowsingActivity
- type CalendarEvent
- type CalendarSync
- type CalendarToken
- type ChatMessage
- type ChatMessageAttachment
- type ChatSettings
- type ChatUsageStats
- type ColumnValueMapper
- type Connector
- type Conversation
- type CredentialUsage
- type DevToken
- type FilesManager
- type Model
- type ModelPreset
- type Newsletter
- type NewsletterEmail
- type NewsletterSettings
- type Notification
- type NotificationSettings
- type StreamEntry
- type Superuser
- type Task
- type Token
- type TrackDevice
- type TrackDeviceAPI
- type TrackDeviceUpdateAPI
- type TrackFocus
- type TrackItems
- type TrackUpload
- type Workflow
- type WorkflowConnection
- type WorkflowExecution
- type WorkflowNode
- type WorkflowResult
Constants ¶
const ( // DefaultIdLength is the default length of the generated model id. DefaultIdLength = 15 // DefaultIdAlphabet is the default characters set used for generating the model id. DefaultIdAlphabet = "abcdefghijklmnopqrstuvwxyz0123456789" )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ApiKey ¶
type ApiKey struct {
BaseModel
User string `db:"user" json:"user"`
Name string `db:"name" json:"name"`
Description string `db:"description" json:"description"`
Service string `db:"service" json:"service"`
Key string `db:"key" json:"key"`
Secret string `db:"secret" json:"secret"`
Scopes types.JsonRaw `db:"scopes" json:"scopes"`
IsActive bool `db:"is_active" json:"is_active"`
Expires types.DateTime `db:"expires" json:"expires"`
}
type BaseModel ¶
type BaseModel struct {
Id string `db:"id" json:"id"`
Created types.DateTime `db:"created" json:"created"`
Updated types.DateTime `db:"updated" json:"updated"`
// contains filtered or unexported fields
}
BaseModel defines common fields and methods used by all other models.
func (*BaseModel) GetCreated ¶
GetCreated returns the model Created datetime.
func (*BaseModel) GetUpdated ¶
GetUpdated returns the model Updated datetime.
func (*BaseModel) IsNew ¶
IsNew indicates what type of db query (insert or update) should be used with the model instance.
func (*BaseModel) MarkAsNew ¶
func (m *BaseModel) MarkAsNew()
MarkAsNew marks the model as "new" (aka. enforces m.IsNew() to be true).
func (*BaseModel) MarkAsNotNew ¶
func (m *BaseModel) MarkAsNotNew()
MarkAsNotNew marks the model as "not new" (aka. enforces m.IsNew() to be false)
func (*BaseModel) PostScan ¶
PostScan implements the [dbx.PostScanner] interface.
It is executed right after the model was populated with the db row values.
func (*BaseModel) RefreshCreated ¶
func (m *BaseModel) RefreshCreated()
RefreshCreated updates the model Created field with the current datetime.
func (*BaseModel) RefreshId ¶
func (m *BaseModel) RefreshId()
RefreshId generates and sets a new model id.
The generated id is a cryptographically random 15 characters length string.
func (*BaseModel) RefreshUpdated ¶
func (m *BaseModel) RefreshUpdated()
RefreshUpdated updates the model Updated field with the current datetime.
type BrowserProfile ¶
type BrowserProfile struct {
BaseModel
User string `db:"user" json:"user"`
Name string `db:"name" json:"name"`
UserAgent string `db:"user_agent" json:"user_agent"`
Platform string `db:"platform" json:"platform"`
IsActive bool `db:"is_active" json:"is_active"`
LastUsed types.DateTime `db:"last_used" json:"last_used"`
}
func (*BrowserProfile) TableName ¶
func (m *BrowserProfile) TableName() string
type BrowsingActivity ¶
type BrowsingActivity struct {
BaseModel
User string `db:"user" json:"user"`
BrowserProfile string `db:"browser_profile" json:"browser_profile"`
URL string `db:"url" json:"url"`
Title string `db:"title" json:"title"`
Domain string `db:"domain" json:"domain"`
StartTime types.DateTime `db:"start_time" json:"start_time"`
EndTime *types.DateTime `db:"end_time" json:"end_time"`
Duration *int `db:"duration" json:"duration"`
TabID *int `db:"tab_id" json:"tab_id"`
WindowID *int `db:"window_id" json:"window_id"`
Audible bool `db:"audible" json:"audible"`
Incognito bool `db:"incognito" json:"incognito"`
Metadata types.JsonRaw `db:"metadata" json:"metadata"`
SessionID string `db:"session_id" json:"session_id"`
}
func (*BrowsingActivity) GetMetadataMap ¶
func (m *BrowsingActivity) GetMetadataMap() (map[string]interface{}, error)
func (*BrowsingActivity) SetMetadataMap ¶
func (m *BrowsingActivity) SetMetadataMap(metadata map[string]interface{}) error
func (*BrowsingActivity) TableName ¶
func (m *BrowsingActivity) TableName() string
type CalendarEvent ¶
type CalendarEvent struct {
BaseModel
CalendarId string `db:"calendar_id" json:"calendar_id"`
CalendarUId string `db:"calendar_uid" json:"calendar_uid"`
User string `db:"user" json:"user"`
Calendar string `db:"calendar" json:"calendar"`
Etag string `db:"etag" json:"etag"`
Summary string `db:"summary" json:"summary"`
Description string `db:"description" json:"description"`
EventType string `db:"event_type" json:"event_type"`
Start types.DateTime `db:"start" json:"start"`
End types.DateTime `db:"end" json:"end"`
Creator string `db:"creator" json:"creator"`
CreatorEmail string `db:"creator_email" json:"creator_email"`
Organizer string `db:"organizer" json:"organizer"`
OrganizerEmail string `db:"organizer_email" json:"organizer_email"`
Kind string `db:"kind" json:"kind"`
Location string `db:"location" json:"location"`
Status string `db:"status" json:"status"`
EventCreated types.DateTime `db:"event_created" json:"event_created"`
EventUpdated types.DateTime `db:"event_updated" json:"event_updated"`
IsDayEvent bool `db:"is_day_event" json:"is_day_event"`
}
func (*CalendarEvent) TableName ¶
func (m *CalendarEvent) TableName() string
type CalendarSync ¶
type CalendarSync struct {
BaseModel
User string `db:"user" json:"user"`
Token string `db:"token" json:"token"`
Name string `db:"name" json:"name"`
Type string `db:"type" json:"type"`
SyncToken string `db:"sync_token" json:"sync_token"`
SyncStatus string `db:"sync_status" json:"sync_status"`
IsActive bool `db:"is_active" json:"is_active"`
InProgress bool `db:"in_progress" json:"in_progress"`
LastSynced types.DateTime `db:"last_synced" json:"last_synced"`
LastFullSyncCheckpoint types.DateTime `db:"last_full_sync_checkpoint" json:"last_full_sync_checkpoint"` // Oldest event date processed during full sync (for crash recovery)
}
func (*CalendarSync) TableName ¶
func (m *CalendarSync) TableName() string
type CalendarToken ¶
type CalendarToken struct {
BaseModel
User string `db:"user" json:"user"`
Account string `db:"account" json:"account"`
AccessToken string `db:"access_token" json:"access_token"`
TokenType string `db:"token_type" json:"token_type"`
RefreshToken string `db:"refresh_token" json:"refresh_token"`
Expiry types.DateTime `db:"expiry" json:"expiry"`
}
func (*CalendarToken) TableName ¶
func (m *CalendarToken) TableName() string
type ChatMessage ¶
type ChatMessage struct {
BaseModel
ConversationID string `db:"conversation" json:"conversation"`
Role string `db:"role" json:"role"` // user, assistant, system
Content string `db:"content" json:"content"`
ModelUsed string `db:"model_used" json:"model_used,omitempty"`
Tokens int `db:"tokens" json:"tokens,omitempty"` // Token count for this message
ParentMessage string `db:"parent_message" json:"parent_message,omitempty"` // For branching
Metadata types.JsonRaw `db:"metadata" json:"metadata,omitempty"` // {files, reactions, sources, reasoning}
}
ChatMessage represents a message in a conversation
func (*ChatMessage) TableName ¶
func (m *ChatMessage) TableName() string
type ChatMessageAttachment ¶
type ChatMessageAttachment struct {
BaseModel
MessageID string `db:"message" json:"message"`
User string `db:"user" json:"user"`
File string `db:"file" json:"file"`
Filename string `db:"filename" json:"filename"`
MimeType string `db:"mime_type" json:"mime_type"`
Size int64 `db:"size" json:"size"`
}
func (*ChatMessageAttachment) TableName ¶
func (m *ChatMessageAttachment) TableName() string
type ChatSettings ¶
type ChatSettings struct {
BaseModel
User string `db:"user" json:"user"` // Unique per user
DefaultModel string `db:"default_model" json:"default_model"`
Theme string `db:"theme" json:"theme"` // "light" | "dark" | "auto"
StatusWindowPosition types.JsonRaw `db:"status_window_position" json:"status_window_position,omitempty"` // {x, y} for Tauri
KeyboardShortcuts types.JsonRaw `db:"keyboard_shortcuts" json:"keyboard_shortcuts,omitempty"` // {new_chat: "cmd+k", export: "cmd+e"}
}
ChatSettings represents user preferences for chat
func (*ChatSettings) TableName ¶
func (m *ChatSettings) TableName() string
type ChatUsageStats ¶
type ChatUsageStats struct {
BaseModel
User string `db:"user" json:"user"`
Conversation string `db:"conversation" json:"conversation,omitempty"`
Date types.DateTime `db:"date" json:"date"`
TokensUsed int `db:"tokens_used" json:"tokens_used"`
RequestsCount int `db:"requests_count" json:"requests_count"`
Cost float64 `db:"cost" json:"cost,omitempty"` // If available
Model string `db:"model" json:"model"`
}
ChatUsageStats represents usage statistics for tracking
func (*ChatUsageStats) TableName ¶
func (m *ChatUsageStats) TableName() string
type ColumnValueMapper ¶
type ColumnValueMapper interface {
// ColumnValueMap returns the data to be used when persisting the model.
ColumnValueMap() map[string]any
}
ColumnValueMapper defines an interface for custom db model data serialization.
type Connector ¶
type Connector struct {
BaseModel
Name string `db:"name" json:"name"`
Type string `db:"type" json:"type"` // source or destination
Category string `db:"category" json:"category"` // email, file, api, etc.
Description string `db:"description" json:"description"`
ConfigSchema string `db:"config_schema" json:"config_schema"` // JSON schema string
Icon string `db:"icon" json:"icon,omitempty"`
}
Connector represents a source or destination connector
type Conversation ¶
type Conversation struct {
BaseModel
User string `db:"user" json:"user"`
Title string `db:"title" json:"title"`
Model string `db:"model" json:"model"` // Model identifier used (e.g., "openai/gpt-4")
SystemPrompt string `db:"system_prompt" json:"system_prompt,omitempty"`
Settings types.JsonRaw `db:"settings" json:"settings,omitempty"` // {temperature, max_tokens, etc.}
IsFavorite bool `db:"is_favorite" json:"is_favorite"`
Tags types.JsonRaw `db:"tags" json:"tags"` // Array of strings: ["coding", "writing"]
Archived bool `db:"archived" json:"archived"`
}
Conversation represents a chat conversation
func (*Conversation) TableName ¶
func (m *Conversation) TableName() string
type CredentialUsage ¶
type CredentialUsage struct {
BaseModel
User string `db:"user" json:"user"`
CredentialType string `db:"credential_type" json:"credential_type"`
CredentialID string `db:"credential_id" json:"credential_id"`
Service string `db:"service" json:"service"`
Endpoint string `db:"endpoint" json:"endpoint"`
Method string `db:"method" json:"method"`
StatusCode int `db:"status_code" json:"status_code"`
ResponseTimeMS float64 `db:"response_time_ms" json:"response_time_ms"`
TokensUsed float64 `db:"tokens_used" json:"tokens_used"`
RequestSizeBytes float64 `db:"request_size_bytes" json:"request_size_bytes"`
ResponseSizeBytes float64 `db:"response_size_bytes" json:"response_size_bytes"`
ErrorType string `db:"error_type" json:"error_type"`
ErrorMessage string `db:"error_message" json:"error_message"`
Timestamp types.DateTime `db:"timestamp" json:"timestamp"`
Metadata types.JsonRaw `db:"metadata" json:"metadata"`
}
func (*CredentialUsage) TableName ¶
func (m *CredentialUsage) TableName() string
type DevToken ¶
type DevToken struct {
BaseModel
User string `db:"user" json:"user"`
Token string `db:"token" json:"token"`
Name string `db:"name" json:"name"`
Environment string `db:"environment" json:"environment"`
IsActive bool `db:"is_active" json:"is_active"`
TotalRequests int `db:"total_requests" json:"total_requests"`
LastUsedAt types.DateTime `db:"last_used_at" json:"last_used_at"`
TotalTokensUsed int `db:"total_tokens_used" json:"total_tokens_used"`
SuccessRate float64 `db:"success_rate" json:"success_rate"`
}
type FilesManager ¶
type FilesManager interface {
// BaseFilesPath returns the storage dir path used by the interface instance.
BaseFilesPath() string
}
FilesManager defines an interface with common methods that files manager models should implement.
type Model ¶
type Model interface {
TableName() string
IsNew() bool
MarkAsNew()
MarkAsNotNew()
HasId() bool
GetId() string
SetId(id string)
GetCreated() types.DateTime
GetUpdated() types.DateTime
RefreshId()
RefreshCreated()
RefreshUpdated()
}
Model defines an interface with common methods that all db models should have.
type ModelPreset ¶
type ModelPreset struct {
BaseModel
User string `db:"user" json:"user"`
Name string `db:"name" json:"name"` // "Creative Writer", "Code Helper"
Model string `db:"model" json:"model"`
Temperature float64 `db:"temperature" json:"temperature"`
MaxTokens int `db:"max_tokens" json:"max_tokens"`
SystemPrompt string `db:"system_prompt" json:"system_prompt,omitempty"`
IsDefault bool `db:"is_default" json:"is_default"`
}
ModelPreset represents saved model configurations
func (*ModelPreset) TableName ¶
func (m *ModelPreset) TableName() string
type Newsletter ¶
type Newsletter struct {
BaseModel
User string `db:"user" json:"user"`
SenderEmail string `db:"sender_email" json:"sender_email"`
SenderName string `db:"sender_name" json:"sender_name"`
Name string `db:"name" json:"name"`
FirstSeen types.DateTime `db:"first_seen" json:"first_seen"`
LastSeen types.DateTime `db:"last_seen" json:"last_seen"`
TotalCount int `db:"total_count" json:"total_count"`
FrequencyDays float64 `db:"frequency_days" json:"frequency_days"`
IsActive bool `db:"is_active" json:"is_active"`
DetectionScore int `db:"detection_score" json:"detection_score"`
DetectionReasons string `db:"detection_reasons" json:"detection_reasons"` // JSON array
}
func (*Newsletter) TableName ¶
func (m *Newsletter) TableName() string
type NewsletterEmail ¶
type NewsletterEmail struct {
BaseModel
Newsletter string `db:"newsletter" json:"newsletter"`
MailMessage string `db:"mail_message" json:"mail_message"`
}
func (*NewsletterEmail) TableName ¶
func (m *NewsletterEmail) TableName() string
type NewsletterSettings ¶
type NewsletterSettings struct {
BaseModel
User string `db:"user" json:"user"`
IsEnabled bool `db:"is_enabled" json:"is_enabled"`
ScanStatus string `db:"scan_status" json:"scan_status"` // pending, scanning, completed, failed
TotalMessages int `db:"total_messages" json:"total_messages"`
ProcessedMessages int `db:"processed_messages" json:"processed_messages"`
DetectedNewsletters int `db:"detected_newsletters" json:"detected_newsletters"`
LastScannedId string `db:"last_scanned_id" json:"last_scanned_id"` // Checkpoint for resume
ErrorMessage string `db:"error_message" json:"error_message"`
ScanStartedAt types.DateTime `db:"scan_started_at" json:"scan_started_at"`
ScanCompletedAt types.DateTime `db:"scan_completed_at" json:"scan_completed_at"`
}
func (*NewsletterSettings) TableName ¶
func (m *NewsletterSettings) TableName() string
type Notification ¶
type Notification struct {
BaseModel
User string `db:"user" json:"user"`
Type string `db:"type" json:"type"`
Title string `db:"title" json:"title"`
Content string `db:"content" json:"content"`
Priority string `db:"priority" json:"priority"`
Status string `db:"status" json:"status"`
Metadata string `db:"metadata" json:"metadata"`
ReadAt types.DateTime `db:"read_at" json:"read_at"`
}
func (*Notification) TableName ¶
func (m *Notification) TableName() string
type NotificationSettings ¶
type NotificationSettings struct {
BaseModel
User string `db:"user" json:"user"`
EmailEnabled bool `db:"email_enabled" json:"email_enabled"`
TypesEnabled types.JsonArray[string] `db:"types_enabled" json:"types_enabled"`
QuietHoursStart string `db:"quiet_hours_start" json:"quiet_hours_start"`
QuietHoursEnd string `db:"quiet_hours_end" json:"quiet_hours_end"`
}
func (*NotificationSettings) TableName ¶
func (m *NotificationSettings) TableName() string
type StreamEntry ¶
type StreamEntry struct {
BaseModel
User string `db:"user" json:"user"`
Content string `db:"content" json:"content"`
Title string `db:"title" json:"title"`
EntryDate types.DateTime `db:"entry_date" json:"entry_date"`
EntryType string `db:"entry_type" json:"entry_type"`
EntryColor string `db:"entry_color" json:"entry_color"`
IsHighlighted bool `db:"is_highlighted" json:"is_highlighted"`
ParentEntry string `db:"parent_entry" json:"parent_entry"`
AIContext types.JsonRaw `db:"ai_context" json:"ai_context"`
}
func (*StreamEntry) TableName ¶
func (m *StreamEntry) TableName() string
type Task ¶
type Token ¶
type Token struct {
BaseModel
User string `db:"user" json:"user"`
Provider string `db:"provider" json:"provider"`
Account string `db:"account" json:"account"`
AccessToken string `db:"access_token" json:"access_token"`
TokenType string `db:"token_type" json:"token_type"`
RefreshToken string `db:"refresh_token" json:"refresh_token"`
Expiry types.DateTime `db:"expiry" json:"expiry"`
Scope string `db:"scope" json:"scope"`
IsActive bool `db:"is_active" json:"is_active"`
LastUsed types.DateTime `db:"last_used" json:"last_used"`
}
type TrackDevice ¶
type TrackDevice struct {
BaseModel
User string `db:"user" json:"user"`
Name string `db:"name" json:"name"`
HostName string `db:"hostname" json:"hostname"`
Os string `db:"os" json:"os"`
Arch string `db:"arch" json:"arch"`
IsOnline bool `db:"is_online" json:"is_online"`
IsActive bool `db:"is_active" json:"is_active"`
IsPublic bool `db:"is_public" json:"is_public"`
SyncEvents bool `db:"sync_events" json:"sync_events"`
LastOnline types.DateTime `db:"last_online" json:"last_online"`
LastSync types.DateTime `db:"last_sync" json:"last_sync"`
}
func (*TrackDevice) TableName ¶
func (m *TrackDevice) TableName() string
type TrackDeviceAPI ¶
type TrackDeviceAPI struct {
Name string `json:"name" form:"name"`
HostName string `json:"hostname" form:"hostname"`
Os string `db:"os" json:"os"`
Arch string `db:"arch" json:"arch"`
}
Use structure embedding
type TrackDeviceUpdateAPI ¶
type TrackFocus ¶
type TrackFocus struct {
BaseModel
User string `db:"user" json:"user"`
Device string `db:"device" json:"device"`
Tags types.JsonArray[string] `db:"tags" json:"tags"`
Metadata string `db:"metadata" json:"metadata"`
BeginDate types.DateTime `db:"begin_date" json:"begin_date"`
EndDate types.DateTime `db:"end_date" json:"end_date"`
}
func (*TrackFocus) TableName ¶
func (m *TrackFocus) TableName() string
type TrackItems ¶
type TrackItems struct {
BaseModel
User string `db:"user" json:"user"`
TrackId int64 `db:"track_id" json:"track_id"`
Device string `db:"device" json:"device"`
App string `db:"app" json:"app"`
TaskName string `db:"task_name" json:"task_name"`
Title string `db:"title" json:"title"`
BeginDate types.DateTime `db:"begin_date" json:"begin_date"`
EndDate types.DateTime `db:"end_date" json:"end_date"`
}
func (*TrackItems) TableName ¶
func (m *TrackItems) TableName() string
type TrackUpload ¶
type TrackUpload struct {
BaseModel
User string `db:"user" json:"user"`
Source string `db:"source" json:"source"`
File string `db:"file" json:"file"`
Synced bool `db:"synced" json:"synced"`
Status string `db:"status" json:"status"`
TotalRecord int64 `db:"total_record" json:"total_record"`
DuplicateRecord int64 `db:"duplicate_record" json:"duplicate_record"`
}
func (*TrackUpload) TableName ¶
func (m *TrackUpload) TableName() string
type Workflow ¶
type Workflow struct {
BaseModel
Name string `db:"name" json:"name"`
Description string `db:"description" json:"description"`
Active bool `db:"active" json:"active"`
User string `db:"user" json:"user"`
Config types.JsonRaw `db:"config" json:"config"`
Timeout int `db:"timeout" json:"timeout"`
MaxRetries int `db:"max_retries" json:"max_retries"`
RetryDelay int `db:"retry_delay" json:"retry_delay"`
}
Workflow represents the core workflow definition
type WorkflowConnection ¶
type WorkflowConnection struct {
BaseModel
WorkflowID string `db:"workflow_id" json:"workflow_id"`
SourceID string `db:"source_id" json:"source_id"` // ID of the source node
TargetID string `db:"target_id" json:"target_id"` // ID of the target node
}
func (*WorkflowConnection) TableName ¶
func (m *WorkflowConnection) TableName() string
type WorkflowExecution ¶
type WorkflowExecution struct {
BaseModel
WorkflowID string `db:"workflow_id" json:"workflow_id"`
Status string `db:"status" json:"status"` // running, completed, failed
StartTime types.DateTime `db:"start_time" json:"start_time"`
EndTime types.DateTime `db:"end_time" json:"end_time"`
Duration int `db:"duration" json:"duration"` // in milliseconds
Logs string `db:"logs" json:"logs"` // JSON string of log entries
Results string `db:"results" json:"results"` // JSON string of results summary
ErrorMessage string `db:"error_message" json:"error_message,omitempty"`
ResultFileIDs string `db:"result_file_ids" json:"result_file_ids,omitempty"` // Comma-separated IDs
}
WorkflowExecution represents the execution history of a workflow
func (*WorkflowExecution) TableName ¶
func (m *WorkflowExecution) TableName() string
type WorkflowNode ¶
type WorkflowNode struct {
BaseModel
WorkflowID string `db:"workflow_id" json:"workflow_id"`
Type string `db:"type" json:"type"` // source, processor, destination
NodeType string `db:"node_type" json:"node_type"` // gmail, csv, http, etc.
Label string `db:"label" json:"label"`
Config string `db:"config" json:"config"` // JSON string
PositionX int `db:"position_x" json:"position_x"` // X coordinate in the editor
PositionY int `db:"position_y" json:"position_y"` // Y coordinate in the editor
}
WorkflowNode represents a single node in a workflow
func (*WorkflowNode) TableName ¶
func (m *WorkflowNode) TableName() string
type WorkflowResult ¶
type WorkflowResult struct {
BaseModel
ExecutionID string `db:"execution_id" json:"execution_id"`
WorkflowID string `db:"workflow_id" json:"workflow_id"`
Data string `db:"data" json:"data"` // JSON string
}
WorkflowResult represents structured output data from a workflow
func (*WorkflowResult) TableName ¶
func (m *WorkflowResult) TableName() string