Documentation
¶
Index ¶
- func InitDB(dbPath string) (*sql.DB, error)
- type DB
- type SQLiteDB
- func (s *SQLiteDB) Close() error
- func (s *SQLiteDB) ExportEntries(filePath string) error
- func (s *SQLiteDB) ExportEntriesSince(filePath string, since time.Time) error
- func (s *SQLiteDB) GetAllEntries() ([]*models.Entry, error)
- func (s *SQLiteDB) GetEntriesByCategory(category models.Category) ([]*models.Entry, error)
- func (s *SQLiteDB) GetEntriesFromLastWeek() ([]*models.Entry, error)
- func (s *SQLiteDB) GetEntriesSince(since time.Time) ([]*models.Entry, error)
- func (s *SQLiteDB) GetEntryByID(id string) (*models.Entry, error)
- func (s *SQLiteDB) GetEntryCount() (int, error)
- func (s *SQLiteDB) ImportEntries(filePath string) (int, error)
- func (s *SQLiteDB) SaveEntry(entry *models.Entry) error
- func (s *SQLiteDB) UpdateEntry(entry *models.Entry) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type DB ¶
type DB interface {
SaveEntry(entry *models.Entry) error
UpdateEntry(entry *models.Entry) error
GetAllEntries() ([]*models.Entry, error)
GetEntriesByCategory(category models.Category) ([]*models.Entry, error)
GetEntryByID(id string) (*models.Entry, error)
GetEntryCount() (int, error)
GetEntriesFromLastWeek() ([]*models.Entry, error)
GetEntriesSince(since time.Time) ([]*models.Entry, error)
ExportEntries(filePath string) error
ExportEntriesSince(filePath string, since time.Time) error
ImportEntries(filePath string) (int, error)
Close() error
}
DB is the interface for database operations
type SQLiteDB ¶
type SQLiteDB struct {
// contains filtered or unexported fields
}
SQLiteDB implements the DB interface with SQLite
func (*SQLiteDB) ExportEntries ¶ added in v0.2.2
ExportEntries exports all entries from the database to a JSON file Each entry is written as a separate JSON object on its own line (JSON Lines format)
func (*SQLiteDB) ExportEntriesSince ¶ added in v0.2.3
ExportEntriesSince exports entries from the database created after the specified time to a JSON file Each entry is written as a separate JSON object on its own line (JSON Lines format)
func (*SQLiteDB) GetAllEntries ¶
GetAllEntries retrieves all entries from the database
func (*SQLiteDB) GetEntriesByCategory ¶
GetEntriesByCategory retrieves entries by category
func (*SQLiteDB) GetEntriesFromLastWeek ¶
GetEntriesFromLastWeek retrieves entries from the past 7 days
func (*SQLiteDB) GetEntriesSince ¶ added in v0.2.3
GetEntriesSince retrieves entries created after the specified time
func (*SQLiteDB) GetEntryByID ¶
GetEntryByID retrieves an entry by ID
func (*SQLiteDB) GetEntryCount ¶
GetEntryCount returns the total number of entries
func (*SQLiteDB) ImportEntries ¶ added in v0.2.3
ImportEntries imports entries from a JSON file into the database