Files
Trackeep/backend/models/note.go
T
Tomas Dvorak d27cf14110 first test
2026-02-08 14:14:55 +01:00

42 lines
1.3 KiB
Go

package models
import (
"time"
"gorm.io/gorm"
)
// Note represents a note or document
type Note struct {
ID uint `json:"id" gorm:"primaryKey"`
CreatedAt time.Time `json:"created_at"`
UpdatedAt time.Time `json:"updated_at"`
DeletedAt gorm.DeletedAt `json:"-" gorm:"index"`
UserID uint `json:"user_id" gorm:"not null;index"`
User User `json:"user,omitempty" gorm:"foreignKey:UserID"`
Title string `json:"title" gorm:"not null"`
Content string `json:"content" gorm:"type:text"`
// Encryption
IsEncrypted bool `json:"is_encrypted" gorm:"default:false"`
EncryptionKey string `json:"-" gorm:"column:encryption_key"` // User-specific encryption key (optional)
// Organization
Tags []Tag `json:"tags,omitempty" gorm:"many2many:note_tags;"`
// Metadata
Description string `json:"description"`
IsPublic bool `json:"is_public" gorm:"default:false"`
IsPinned bool `json:"is_pinned" gorm:"default:false"`
// Formatting
ContentType string `json:"content_type" gorm:"default:markdown"` // markdown, html, plain
// Relationships
ParentNoteID *uint `json:"parent_note_id,omitempty"`
ParentNote *Note `json:"parent_note,omitempty" gorm:"foreignKey:ParentNoteID"`
Subnotes []Note `json:"subnotes,omitempty" gorm:"foreignKey:ParentNoteID"`
}