database

package
v0.9.4 Latest Latest
Warning

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

Go to latest
Published: Jun 8, 2025 License: AGPL-3.0 Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CacheMode added in v0.4.0

type CacheMode string

CacheMode represents the available cache modes for SQLite

const (
	CacheShared  CacheMode = "shared"
	CachePrivate CacheMode = "private"
)

type DB

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

DB manages the database connection

func New

func New(opts SQLiteOptions) (*DB, error)

New creates a new database connection using the provided options. It configures the connection using both DSN parameters (for supported options like mode, cache, immutable) and explicit PRAGMA commands executed after the connection is established for other settings.

func (*DB) Close

func (db *DB) Close() error

Close closes the database connection

func (*DB) Conn

func (db *DB) Conn() *sql.DB

Conn returns the underlying database connection

func (*DB) MigrateDatabase

func (db *DB) MigrateDatabase() error

MigrateDatabase performs database migrations

type JournalMode added in v0.4.0

type JournalMode string

JournalMode represents the available journal modes for SQLite

const (
	JournalDelete   JournalMode = "DELETE"
	JournalTruncate JournalMode = "TRUNCATE"
	JournalPersist  JournalMode = "PERSIST"
	JournalMemory   JournalMode = "MEMORY"
	JournalWAL      JournalMode = "WAL"
	JournalOff      JournalMode = "OFF"
)

type LockingMode added in v0.4.0

type LockingMode string

LockingMode represents the available locking modes for SQLite

const (
	LockingNormal    LockingMode = "NORMAL"
	LockingExclusive LockingMode = "EXCLUSIVE"
)

type NotificationChannel

type NotificationChannel struct {
	ID         string
	ResourceID string
	CalendarID string
	Expiration time.Time
	CreatedAt  time.Time
	UpdatedAt  time.Time
}

NotificationChannel represents a Google Calendar notification channel

type SQLiteOptions added in v0.4.0

type SQLiteOptions struct {
	// Path to the SQLite database file
	Path string

	// Core Options
	Mode        string          // ro, rw, rwc, memory
	Journal     JournalMode     // _journal_mode: DELETE, TRUNCATE, PERSIST, MEMORY, WAL, OFF
	ForeignKeys bool            // _foreign_keys=true
	BusyTimeout int             // _busy_timeout (milliseconds)
	CacheSize   int             // _cache_size (in KB, negative for number of pages)
	Synchronous SynchronousMode // _synchronous: OFF, NORMAL, FULL, EXTRA
	Cache       CacheMode       // shared, private
	Immutable   bool            // immutable=true/false

	// Transaction & Locking
	LockingMode  LockingMode // _locking_mode: NORMAL, EXCLUSIVE
	TxLock       string      // _txlock: immediate, deferred, exclusive
	MutexLocking string      // _mutex: no, full

	// Advanced Options
	AutoVacuum             string // _auto_vacuum: none, full, incremental
	CaseSensitiveLike      bool   // _case_sensitive_like
	DeferForeignKeys       bool   // _defer_foreign_keys
	IgnoreCheckConstraints bool   // _ignore_check_constraints
	QueryOnly              bool   // _query_only
	RecursiveTriggers      bool   // _recursive_triggers
	SecureDelete           string // _secure_delete: boolean or "FAST"
	WritableSchema         bool   // _writable_schema

	// Authentication
	Auth      bool   // _auth
	AuthUser  string // _auth_user
	AuthPass  string // _auth_pass
	AuthCrypt string // _auth_crypt: SHA1, SSHA1, SHA256, etc.
	AuthSalt  string // _auth_salt
}

SQLiteOptions contains configuration options for SQLite connection

func NewDefaultOptions added in v0.4.0

func NewDefaultOptions(path string) SQLiteOptions

NewDefaultOptions creates SQLiteOptions with recommended defaults

type SynchronousMode added in v0.4.0

type SynchronousMode string

SynchronousMode represents the available synchronous settings for SQLite

const (
	SynchronousOff    SynchronousMode = "OFF"
	SynchronousNormal SynchronousMode = "NORMAL"
	SynchronousFull   SynchronousMode = "FULL"
	SynchronousExtra  SynchronousMode = "EXTRA"
)

type TokenStore

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

TokenStore handles OAuth token storage in SQLite

func NewTokenStore

func NewTokenStore(db *DB) (*TokenStore, error)

NewTokenStore creates a new token store

func (*TokenStore) ClearToken

func (s *TokenStore) ClearToken() error

ClearToken removes the saved OAuth token

func (*TokenStore) DeleteExpiredNotificationChannels

func (s *TokenStore) DeleteExpiredNotificationChannels() error

DeleteExpiredNotificationChannels deletes all expired notification channels

func (*TokenStore) DeleteNotificationChannel

func (s *TokenStore) DeleteNotificationChannel(id string) error

DeleteNotificationChannel deletes a notification channel by its ID

func (*TokenStore) GetActiveNotificationChannels

func (s *TokenStore) GetActiveNotificationChannels() ([]*NotificationChannel, error)

GetActiveNotificationChannels retrieves all active notification channels

func (*TokenStore) GetNotificationChannelByID

func (s *TokenStore) GetNotificationChannelByID(id string) (*NotificationChannel, error)

GetNotificationChannelByID retrieves a notification channel by its ID

func (*TokenStore) GetSelectedCalendar

func (s *TokenStore) GetSelectedCalendar() (string, error)

GetSelectedCalendar retrieves the saved calendar ID

func (*TokenStore) GetToken

func (s *TokenStore) GetToken() (*oauth2.Token, error)

GetToken retrieves the saved OAuth token

func (*TokenStore) SaveNotificationChannel

func (s *TokenStore) SaveNotificationChannel(channel *NotificationChannel) error

SaveNotificationChannel saves a notification channel

func (*TokenStore) SaveSelectedCalendar

func (s *TokenStore) SaveSelectedCalendar(calendarID string) error

SaveSelectedCalendar saves the selected calendar ID

func (*TokenStore) SaveToken

func (s *TokenStore) SaveToken(token *oauth2.Token) error

SaveToken implements the TokenSaver interface

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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