database

package
v1.2.2 Latest Latest
Warning

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

Go to latest
Published: Aug 4, 2025 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type DB

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

DB represents the database connection

func Open

func Open(dbPath string) (*DB, error)

Open opens the database connection

func (*DB) CleanupMissingFiles

func (db *DB) CleanupMissingFiles() ([]string, error)

CleanupMissingFiles removes database entries for files that no longer exist on disk

func (*DB) Close

func (db *DB) Close() error

Close closes the database connection

func (*DB) CountImages

func (db *DB) CountImages() (int, error)

CountImages returns the total number of images

func (*DB) DeleteImage

func (db *DB) DeleteImage(id int) (string, error)

DeleteImage deletes an image by ID and returns the local path

func (*DB) DeleteImageBySourceID

func (db *DB) DeleteImageBySourceID(source, sourceID string) (string, error)

DeleteImageBySourceID deletes an image by source and source_id

func (*DB) DeleteOldImages

func (db *DB) DeleteOldImages(keepCount int) ([]string, error)

DeleteOldImages deletes old images keeping only the most recent ones

func (*DB) ExistsByChecksum

func (db *DB) ExistsByChecksum(checksum string) (bool, error)

ExistsByChecksum checks if an image exists by checksum

func (*DB) ExistsBySourceID

func (db *DB) ExistsBySourceID(source, sourceID string) (bool, error)

ExistsBySourceID checks if an image exists by source and source ID

func (*DB) FindDuplicates

func (db *DB) FindDuplicates() ([][]Image, error)

FindDuplicates finds duplicate images by checksum

func (*DB) GetImageByID

func (db *DB) GetImageByID(id int) (*Image, error)

GetImageByID gets an image by ID

func (*DB) InsertImage

func (db *DB) InsertImage(img *Image) error

InsertImage inserts a new image record

func (*DB) ListImages

func (db *DB) ListImages(source string, limit int) ([]Image, error)

ListImages lists images with optional filtering

type Image

type Image struct {
	ID           int       `json:"id"`
	Source       string    `json:"source"`
	SourceID     string    `json:"source_id"`
	URL          string    `json:"url"`
	LocalPath    string    `json:"local_path"`
	Checksum     string    `json:"checksum"`
	Tags         string    `json:"tags"`
	Resolution   string    `json:"resolution"`
	FileSize     int64     `json:"file_size"`
	DownloadedAt time.Time `json:"downloaded_at"`
}

Image represents an image record in the database

Jump to

Keyboard shortcuts

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