storage

package
v1.0.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 7, 2026 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrNoteNotFound      = errors.New("note not found")
	ErrNoteIDRequired    = errors.New("note ID is required")
	ErrSyncStateNotFound = errors.New("sync state not found")
	ErrSyncJobNotFound   = errors.New("sync job not found")
)

Functions

This section is empty.

Types

type Note

type Note struct {
	ID          string    `json:"id"`
	Filename    string    `json:"filename"`
	Title       string    `json:"title"`
	Path        string    `json:"path"`
	Folder      string    `json:"folder"`
	ContentHash string    `json:"content_hash"`
	WordCount   int       `json:"word_count"`
	CreatedAt   time.Time `json:"created_at"`
	ModifiedAt  time.Time `json:"modified_at"`
	Archived    bool      `json:"archived"`
	Pinned      bool      `json:"pinned"`
	Content     string    `json:"-"` // full text for FTS indexing (not stored in notes table)
	Tags        []string  `json:"tags"`
}

type NoteStore

type NoteStore struct {
	// contains filtered or unexported fields
}

func NewNoteStore

func NewNoteStore(vaultDir string) *NoteStore

func (*NoteStore) AddSyncHistory

func (s *NoteStore) AddSyncHistory(entry *SyncHistoryEntry) error

func (*NoteStore) Close

func (s *NoteStore) Close() error

func (*NoteStore) CreateNote

func (s *NoteStore) CreateNote(note *Note) error

func (*NoteStore) DeleteNote

func (s *NoteStore) DeleteNote(id string) error

func (*NoteStore) DeleteSyncState

func (s *NoteStore) DeleteSyncState(noteID, backend string) error

func (*NoteStore) DequeueSyncJob

func (s *NoteStore) DequeueSyncJob() (*SyncQueueItem, error)

func (*NoteStore) EnqueueSyncJob

func (s *NoteStore) EnqueueSyncJob(noteID string, backends []string, direction string, attempts int) error

func (*NoteStore) FindNoteByFilename

func (s *NoteStore) FindNoteByFilename(filename string) (*Note, error)

func (*NoteStore) GetNote

func (s *NoteStore) GetNote(id string) (*Note, error)

func (*NoteStore) GetSyncState

func (s *NoteStore) GetSyncState(noteID, backend string) (*SyncState, error)

func (*NoteStore) GetVersion

func (s *NoteStore) GetVersion(noteID string, versionNum int) (*Version, error)

func (*NoteStore) Init

func (s *NoteStore) Init() error

func (*NoteStore) ListNotes

func (s *NoteStore) ListNotes() ([]*Note, error)

func (*NoteStore) ListNotesByTag

func (s *NoteStore) ListNotesByTag(tag string) ([]*Note, error)

func (*NoteStore) ListRecentSyncHistory

func (s *NoteStore) ListRecentSyncHistory(limit int) ([]*SyncHistoryEntry, error)

func (*NoteStore) ListSyncHistory

func (s *NoteStore) ListSyncHistory(noteID string) ([]*SyncHistoryEntry, error)

func (*NoteStore) ListSyncStates

func (s *NoteStore) ListSyncStates() ([]*SyncState, error)

func (*NoteStore) ListSyncStatesByStatus

func (s *NoteStore) ListSyncStatesByStatus(status string) ([]*SyncState, error)

func (*NoteStore) ListVersions

func (s *NoteStore) ListVersions(noteID string) ([]*Version, error)

func (*NoteStore) QueueLength

func (s *NoteStore) QueueLength() (int, error)

func (*NoteStore) SaveVersion

func (s *NoteStore) SaveVersion(noteID string, content string, trigger string) (*Version, error)

func (*NoteStore) SearchNotes

func (s *NoteStore) SearchNotes(query string) ([]*Note, error)

func (*NoteStore) UpdateNote

func (s *NoteStore) UpdateNote(note *Note) error

func (*NoteStore) UpsertSyncState

func (s *NoteStore) UpsertSyncState(state *SyncState) error

type Store

type Store interface {
	Init() error
	CreateNote(note *Note) error
	GetNote(id string) (*Note, error)
	FindNoteByFilename(filename string) (*Note, error)
	UpdateNote(note *Note) error
	DeleteNote(id string) error
	ListNotes() ([]*Note, error)
	ListNotesByTag(tag string) ([]*Note, error)
	SearchNotes(query string) ([]*Note, error)
	Close() error

	GetSyncState(noteID, backend string) (*SyncState, error)
	UpsertSyncState(state *SyncState) error
	DeleteSyncState(noteID, backend string) error
	ListSyncStates() ([]*SyncState, error)
	ListSyncStatesByStatus(status string) ([]*SyncState, error)
	EnqueueSyncJob(noteID string, backends []string, direction string, attempts int) error
	DequeueSyncJob() (*SyncQueueItem, error)
	QueueLength() (int, error)
	AddSyncHistory(entry *SyncHistoryEntry) error
	ListSyncHistory(noteID string) ([]*SyncHistoryEntry, error)
	SaveVersion(noteID string, content string, trigger string) (*Version, error)
	ListVersions(noteID string) ([]*Version, error)
	GetVersion(noteID string, versionNum int) (*Version, error)
}

type SyncHistoryEntry

type SyncHistoryEntry struct {
	ID        int64     `json:"id"`
	NoteID    string    `json:"note_id"`
	Backend   string    `json:"backend"`
	Direction string    `json:"direction"`
	Status    string    `json:"status"`
	SyncedAt  time.Time `json:"synced_at"`
	Hash      string    `json:"hash,omitempty"`
}

type SyncQueueItem

type SyncQueueItem struct {
	ID        int64     `json:"id"`
	NoteID    string    `json:"note_id"`
	Backends  []string  `json:"backends"`
	Direction string    `json:"direction"`
	QueuedAt  time.Time `json:"queued_at"`
	Attempts  int       `json:"attempts"`
	LastError string    `json:"last_error,omitempty"`
}

type SyncState

type SyncState struct {
	NoteID     string    `json:"note_id"`
	Backend    string    `json:"backend"`
	RemoteID   string    `json:"remote_id,omitempty"`
	LastSyncAt time.Time `json:"last_sync_at,omitempty"`
	LastHash   string    `json:"last_hash,omitempty"`
	Status     string    `json:"status"`
	ErrorMsg   string    `json:"error_msg,omitempty"`
}

type Version

type Version struct {
	ID         int64     `json:"id"`
	NoteID     string    `json:"note_id"`
	VersionNum int       `json:"version_num"`
	Content    string    `json:"content"`
	SavedAt    time.Time `json:"saved_at"`
	Trigger    string    `json:"trigger"`
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL