storage

package
v0.0.16 Latest Latest
Warning

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

Go to latest
Published: Oct 7, 2024 License: MIT Imports: 19 Imported by: 0

Documentation

Overview

Package storage provides database-related implementations.

Index

Constants

View Source
const (
	// AlbumTable is the name of the table.
	AlbumTable = "album"

	// AlbumImageTable is the name of the table.
	AlbumImageTable = "album_image"
)
View Source
const ErrMissingHash = ctxd.SentinelError("missing hash")
View Source
const (
	// ExifTable is the name of the table.
	ExifTable = "exif"
)
View Source
const (
	// GpsTable is the name of the table.
	GpsTable = "gps"
)
View Source
const (
	// GpxTable is the name of the table.
	GpxTable = "gpx"
)
View Source
const (
	// ImageTable is the name of the table.
	ImageTable = "image"
)
View Source
const (
	// MessageTable is the name of the table.
	MessageTable = "message"
)
View Source
const (
	// MetaTable is the name of the table.
	MetaTable = "meta"
)
View Source
const (
	// SettingsTable is the name of the table.
	SettingsTable = "settings"
)
View Source
const (
	// ThreadTable is the name of the table.
	ThreadTable = "thread"
)
View Source
const (
	// ThumbTable is the name of the table.
	ThumbTable = "thumb"
)
View Source
const (
	// VisitorTable is the name of the table.
	VisitorTable = "visitor"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type AlbumImage

type AlbumImage struct {
	AlbumHash uniq.Hash  `db:"album_hash"`
	ImageHash uniq.Hash  `db:"image_hash"`
	Timestamp *time.Time `db:"timestamp"`
}

AlbumImage describes database mapping.

type AlbumRepository

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

AlbumRepository saves images to database.

func NewAlbumRepository

func NewAlbumRepository(storage *sqluct.Storage, ir *ImageRepository, mr *MetaRepository) *AlbumRepository

func (*AlbumRepository) Add

func (ir *AlbumRepository) Add(ctx context.Context, value V) error

func (*AlbumRepository) AddImages

func (r *AlbumRepository) AddImages(ctx context.Context, albumHash uniq.Hash, imageHashes ...uniq.Hash) error

func (*AlbumRepository) Delete

func (ir *AlbumRepository) Delete(ctx context.Context, h uniq.Hash) error

func (*AlbumRepository) DeleteImages

func (r *AlbumRepository) DeleteImages(ctx context.Context, albumHash uniq.Hash, imageHashes ...uniq.Hash) error

func (*AlbumRepository) Ensure

func (ir *AlbumRepository) Ensure(ctx context.Context, value V, options ...uniq.EnsureOption[V]) (V, error)

func (*AlbumRepository) Exists

func (ir *AlbumRepository) Exists(ctx context.Context, hash uniq.Hash) (bool, error)

func (*AlbumRepository) FindAll

func (ir *AlbumRepository) FindAll(ctx context.Context) ([]V, error)

func (*AlbumRepository) FindBrokenImages added in v0.0.9

func (r *AlbumRepository) FindBrokenImages(ctx context.Context) ([]photo.Image, error)

func (*AlbumRepository) FindByHash

func (ir *AlbumRepository) FindByHash(ctx context.Context, hash uniq.Hash) (V, error)

func (*AlbumRepository) FindByHashes

func (ir *AlbumRepository) FindByHashes(ctx context.Context, hashes ...uniq.Hash) ([]V, error)

func (*AlbumRepository) FindByName

func (r *AlbumRepository) FindByName(ctx context.Context, name string) (photo.Album, error)

func (*AlbumRepository) FindImageAlbums added in v0.0.9

func (r *AlbumRepository) FindImageAlbums(ctx context.Context, excludeAlbum uniq.Hash, imageHashes ...uniq.Hash) (map[uniq.Hash][]photo.Album, error)

func (*AlbumRepository) FindImages

func (r *AlbumRepository) FindImages(ctx context.Context, albumHash uniq.Hash) ([]photo.Image, error)

func (*AlbumRepository) FindOrphanImages added in v0.0.9

func (r *AlbumRepository) FindOrphanImages(ctx context.Context) ([]photo.Image, error)

func (*AlbumRepository) FindPreviewImages

func (r *AlbumRepository) FindPreviewImages(ctx context.Context, albumHash uniq.Hash, coverImage uniq.Hash, limit uint64) ([]photo.Image, error)

func (*AlbumRepository) PhotoAlbumDeleter

func (r *AlbumRepository) PhotoAlbumDeleter() uniq.Deleter[photo.Album]

func (*AlbumRepository) PhotoAlbumEnsurer

func (r *AlbumRepository) PhotoAlbumEnsurer() uniq.Ensurer[photo.Album]

func (*AlbumRepository) PhotoAlbumFinder

func (r *AlbumRepository) PhotoAlbumFinder() uniq.Finder[photo.Album]

func (*AlbumRepository) PhotoAlbumImageAdder

func (r *AlbumRepository) PhotoAlbumImageAdder() photo.AlbumImageAdder

func (*AlbumRepository) PhotoAlbumImageDeleter

func (r *AlbumRepository) PhotoAlbumImageDeleter() photo.AlbumImageDeleter

func (*AlbumRepository) PhotoAlbumImageFinder

func (r *AlbumRepository) PhotoAlbumImageFinder() photo.AlbumImageFinder

func (*AlbumRepository) PhotoAlbumUpdater

func (r *AlbumRepository) PhotoAlbumUpdater() uniq.Updater[photo.Album]

func (*AlbumRepository) SearchImages added in v0.0.12

func (r *AlbumRepository) SearchImages(ctx context.Context, query string) ([]photo.Image, error)

func (*AlbumRepository) SearchImages2 added in v0.0.12

func (r *AlbumRepository) SearchImages2(ctx context.Context, query string) ([]photo.Image, error)

func (*AlbumRepository) SetAlbumImageTimestamp added in v0.0.12

func (r *AlbumRepository) SetAlbumImageTimestamp(ctx context.Context, album uniq.Hash, img uniq.Hash, ts time.Time) error

func (*AlbumRepository) Update

func (ir *AlbumRepository) Update(ctx context.Context, value V) error

type ExifRepository

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

ExifRepository saves images to database.

func NewExifRepository

func NewExifRepository(storage *sqluct.Storage) *ExifRepository

func (*ExifRepository) Add

func (ir *ExifRepository) Add(ctx context.Context, value V) error

func (*ExifRepository) Delete

func (ir *ExifRepository) Delete(ctx context.Context, h uniq.Hash) error

func (*ExifRepository) Ensure

func (ir *ExifRepository) Ensure(ctx context.Context, value V, options ...uniq.EnsureOption[V]) (V, error)

func (*ExifRepository) Exists

func (ir *ExifRepository) Exists(ctx context.Context, hash uniq.Hash) (bool, error)

func (*ExifRepository) FindAll

func (ir *ExifRepository) FindAll(ctx context.Context) ([]V, error)

func (*ExifRepository) FindByHash

func (ir *ExifRepository) FindByHash(ctx context.Context, hash uniq.Hash) (V, error)

func (*ExifRepository) FindByHashes

func (ir *ExifRepository) FindByHashes(ctx context.Context, hashes ...uniq.Hash) ([]V, error)

func (*ExifRepository) PhotoExifEnsurer

func (ir *ExifRepository) PhotoExifEnsurer() uniq.Ensurer[photo.Exif]

func (*ExifRepository) PhotoExifFinder

func (ir *ExifRepository) PhotoExifFinder() uniq.Finder[photo.Exif]

func (*ExifRepository) Update

func (ir *ExifRepository) Update(ctx context.Context, value V) error

type GpsRepository

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

GpsRepository saves images to database.

func NewGpsRepository

func NewGpsRepository(storage *sqluct.Storage) *GpsRepository

func (*GpsRepository) Add

func (ir *GpsRepository) Add(ctx context.Context, value V) error

func (*GpsRepository) Delete

func (ir *GpsRepository) Delete(ctx context.Context, h uniq.Hash) error

func (*GpsRepository) Ensure

func (ir *GpsRepository) Ensure(ctx context.Context, value V, options ...uniq.EnsureOption[V]) (V, error)

func (*GpsRepository) Exists

func (ir *GpsRepository) Exists(ctx context.Context, hash uniq.Hash) (bool, error)

func (*GpsRepository) FindAll

func (ir *GpsRepository) FindAll(ctx context.Context) ([]V, error)

func (*GpsRepository) FindByHash

func (ir *GpsRepository) FindByHash(ctx context.Context, hash uniq.Hash) (V, error)

func (*GpsRepository) FindByHashes

func (ir *GpsRepository) FindByHashes(ctx context.Context, hashes ...uniq.Hash) ([]V, error)

func (*GpsRepository) PhotoGpsEnsurer

func (ir *GpsRepository) PhotoGpsEnsurer() uniq.Ensurer[photo.Gps]

func (*GpsRepository) PhotoGpsFinder

func (ir *GpsRepository) PhotoGpsFinder() uniq.Finder[photo.Gps]

func (*GpsRepository) Update

func (ir *GpsRepository) Update(ctx context.Context, value V) error

type GpxRepository

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

GpxRepository saves images to database.

func NewGpxRepository

func NewGpxRepository(storage *sqluct.Storage) *GpxRepository

func (*GpxRepository) Add

func (ir *GpxRepository) Add(ctx context.Context, value V) error

func (*GpxRepository) Delete

func (ir *GpxRepository) Delete(ctx context.Context, h uniq.Hash) error

func (*GpxRepository) Ensure

func (ir *GpxRepository) Ensure(ctx context.Context, value V, options ...uniq.EnsureOption[V]) (V, error)

func (*GpxRepository) Exists

func (ir *GpxRepository) Exists(ctx context.Context, hash uniq.Hash) (bool, error)

func (*GpxRepository) FindAll

func (ir *GpxRepository) FindAll(ctx context.Context) ([]V, error)

func (*GpxRepository) FindByHash

func (ir *GpxRepository) FindByHash(ctx context.Context, hash uniq.Hash) (V, error)

func (*GpxRepository) FindByHashes

func (ir *GpxRepository) FindByHashes(ctx context.Context, hashes ...uniq.Hash) ([]V, error)

func (*GpxRepository) PhotoGpxEnsurer

func (ir *GpxRepository) PhotoGpxEnsurer() uniq.Ensurer[photo.Gpx]

func (*GpxRepository) PhotoGpxFinder

func (ir *GpxRepository) PhotoGpxFinder() uniq.Finder[photo.Gpx]

func (*GpxRepository) PhotoGpxUpdater

func (ir *GpxRepository) PhotoGpxUpdater() uniq.Updater[photo.Gpx]

func (*GpxRepository) Update

func (ir *GpxRepository) Update(ctx context.Context, value V) error

type ImageRepository

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

ImageRepository saves images to database.

func NewImageRepository

func NewImageRepository(storage *sqluct.Storage) *ImageRepository

func (*ImageRepository) Add

func (ir *ImageRepository) Add(ctx context.Context, value V) error

func (*ImageRepository) Delete

func (ir *ImageRepository) Delete(ctx context.Context, h uniq.Hash) error

func (*ImageRepository) Ensure

func (ir *ImageRepository) Ensure(ctx context.Context, value V, options ...uniq.EnsureOption[V]) (V, error)

func (*ImageRepository) Exists

func (ir *ImageRepository) Exists(ctx context.Context, hash uniq.Hash) (bool, error)

func (*ImageRepository) FindAll

func (ir *ImageRepository) FindAll(ctx context.Context) ([]V, error)

func (*ImageRepository) FindByHash

func (ir *ImageRepository) FindByHash(ctx context.Context, hash uniq.Hash) (V, error)

func (*ImageRepository) FindByHashes

func (ir *ImageRepository) FindByHashes(ctx context.Context, hashes ...uniq.Hash) ([]V, error)

func (*ImageRepository) PhotoImageEnsurer

func (ir *ImageRepository) PhotoImageEnsurer() uniq.Ensurer[photo.Image]

func (*ImageRepository) PhotoImageFinder

func (ir *ImageRepository) PhotoImageFinder() uniq.Finder[photo.Image]

func (*ImageRepository) PhotoImageUpdater

func (ir *ImageRepository) PhotoImageUpdater() uniq.Updater[photo.Image]

func (*ImageRepository) Update

func (ir *ImageRepository) Update(ctx context.Context, value V) error

type MessageRepository added in v0.0.6

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

MessageRepository saves images to database.

func NewMessageRepository added in v0.0.6

func NewMessageRepository(storage *sqluct.Storage) *MessageRepository

func (*MessageRepository) Add added in v0.0.6

func (ir *MessageRepository) Add(ctx context.Context, value V) error

func (*MessageRepository) CommentMessageEnsurer added in v0.0.6

func (ir *MessageRepository) CommentMessageEnsurer() uniq.Ensurer[comment.Message]

func (*MessageRepository) CommentMessageFinder added in v0.0.6

func (ir *MessageRepository) CommentMessageFinder() uniq.Finder[comment.Message]

func (*MessageRepository) Delete added in v0.0.6

func (ir *MessageRepository) Delete(ctx context.Context, h uniq.Hash) error

func (*MessageRepository) Ensure added in v0.0.6

func (ir *MessageRepository) Ensure(ctx context.Context, value V, options ...uniq.EnsureOption[V]) (V, error)

func (*MessageRepository) Exists added in v0.0.6

func (ir *MessageRepository) Exists(ctx context.Context, hash uniq.Hash) (bool, error)

func (*MessageRepository) FindAll added in v0.0.6

func (ir *MessageRepository) FindAll(ctx context.Context) ([]V, error)

func (*MessageRepository) FindByHash added in v0.0.6

func (ir *MessageRepository) FindByHash(ctx context.Context, hash uniq.Hash) (V, error)

func (*MessageRepository) FindByHashes added in v0.0.6

func (ir *MessageRepository) FindByHashes(ctx context.Context, hashes ...uniq.Hash) ([]V, error)

func (*MessageRepository) Update added in v0.0.6

func (ir *MessageRepository) Update(ctx context.Context, value V) error

type MetaRepository added in v0.0.12

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

MetaRepository saves meta data of hashed entities to database.

func NewMetaRepository added in v0.0.12

func NewMetaRepository(storage *sqluct.Storage) *MetaRepository

func (*MetaRepository) Add added in v0.0.12

func (ir *MetaRepository) Add(ctx context.Context, value V) error

func (*MetaRepository) Delete added in v0.0.12

func (ir *MetaRepository) Delete(ctx context.Context, h uniq.Hash) error

func (*MetaRepository) Ensure added in v0.0.12

func (ir *MetaRepository) Ensure(ctx context.Context, value V, options ...uniq.EnsureOption[V]) (V, error)

func (*MetaRepository) Exists added in v0.0.12

func (ir *MetaRepository) Exists(ctx context.Context, hash uniq.Hash) (bool, error)

func (*MetaRepository) FindAll added in v0.0.12

func (ir *MetaRepository) FindAll(ctx context.Context) ([]V, error)

func (*MetaRepository) FindByHash added in v0.0.12

func (ir *MetaRepository) FindByHash(ctx context.Context, hash uniq.Hash) (V, error)

func (*MetaRepository) FindByHashes added in v0.0.12

func (ir *MetaRepository) FindByHashes(ctx context.Context, hashes ...uniq.Hash) ([]V, error)

func (*MetaRepository) PhotoMetaEnsurer added in v0.0.12

func (ir *MetaRepository) PhotoMetaEnsurer() uniq.Ensurer[photo.Meta]

func (*MetaRepository) PhotoMetaFinder added in v0.0.12

func (ir *MetaRepository) PhotoMetaFinder() uniq.Finder[photo.Meta]

func (*MetaRepository) PhotoMetaUpdater added in v0.0.12

func (ir *MetaRepository) PhotoMetaUpdater() uniq.Updater[photo.Meta]

func (*MetaRepository) Update added in v0.0.12

func (ir *MetaRepository) Update(ctx context.Context, value V) error

type SettingsRepository

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

func NewSettingsRepository

func NewSettingsRepository(storage *sqluct.Storage) *SettingsRepository

func (*SettingsRepository) Get

func (r *SettingsRepository) Get(ctx context.Context, name string, value any) error

func (*SettingsRepository) Set

func (r *SettingsRepository) Set(ctx context.Context, name string, value any) error

type ThreadRepository added in v0.0.6

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

ThreadRepository saves images to database.

func NewThreadRepository added in v0.0.6

func NewThreadRepository(storage *sqluct.Storage) *ThreadRepository

func (*ThreadRepository) Add added in v0.0.6

func (ir *ThreadRepository) Add(ctx context.Context, value V) error

func (*ThreadRepository) CommentThreadEnsurer added in v0.0.6

func (ir *ThreadRepository) CommentThreadEnsurer() uniq.Ensurer[comment.Thread]

func (*ThreadRepository) CommentThreadFinder added in v0.0.6

func (ir *ThreadRepository) CommentThreadFinder() uniq.Finder[comment.Thread]

func (*ThreadRepository) Delete added in v0.0.6

func (ir *ThreadRepository) Delete(ctx context.Context, h uniq.Hash) error

func (*ThreadRepository) Ensure added in v0.0.6

func (ir *ThreadRepository) Ensure(ctx context.Context, value V, options ...uniq.EnsureOption[V]) (V, error)

func (*ThreadRepository) Exists added in v0.0.6

func (ir *ThreadRepository) Exists(ctx context.Context, hash uniq.Hash) (bool, error)

func (*ThreadRepository) FindAll added in v0.0.6

func (ir *ThreadRepository) FindAll(ctx context.Context) ([]V, error)

func (*ThreadRepository) FindByHash added in v0.0.6

func (ir *ThreadRepository) FindByHash(ctx context.Context, hash uniq.Hash) (V, error)

func (*ThreadRepository) FindByHashes added in v0.0.6

func (ir *ThreadRepository) FindByHashes(ctx context.Context, hashes ...uniq.Hash) ([]V, error)

func (*ThreadRepository) Update added in v0.0.6

func (ir *ThreadRepository) Update(ctx context.Context, value V) error

type ThumbRepository

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

ThumbRepository saves images to database.

func NewThumbRepository

func NewThumbRepository(storage *sqluct.Storage, upstream photo.Thumbnailer, logger ctxd.Logger) *ThumbRepository

func (*ThumbRepository) Add

func (ir *ThumbRepository) Add(ctx context.Context, value V) error

func (*ThumbRepository) Delete

func (ir *ThumbRepository) Delete(ctx context.Context, h uniq.Hash) error

func (*ThumbRepository) Ensure

func (ir *ThumbRepository) Ensure(ctx context.Context, value V, options ...uniq.EnsureOption[V]) (V, error)

func (*ThumbRepository) Exists

func (ir *ThumbRepository) Exists(ctx context.Context, hash uniq.Hash) (bool, error)

func (*ThumbRepository) Find

func (tr *ThumbRepository) Find(ctx context.Context, imageHash uniq.Hash, width, height uint) (photo.Thumb, error)

func (*ThumbRepository) FindAll

func (ir *ThumbRepository) FindAll(ctx context.Context) ([]V, error)

func (*ThumbRepository) FindByHash

func (ir *ThumbRepository) FindByHash(ctx context.Context, hash uniq.Hash) (V, error)

func (*ThumbRepository) FindByHashes

func (ir *ThumbRepository) FindByHashes(ctx context.Context, hashes ...uniq.Hash) ([]V, error)

func (*ThumbRepository) FindLarger

func (tr *ThumbRepository) FindLarger(ctx context.Context, imageHash uniq.Hash, width, height uint) (photo.Thumb, error)

func (*ThumbRepository) PhotoThumbnailer

func (tr *ThumbRepository) PhotoThumbnailer() photo.Thumbnailer

func (*ThumbRepository) Thumbnail

func (tr *ThumbRepository) Thumbnail(ctx context.Context, img photo.Image, size photo.ThumbSize) (photo.Thumb, error)

func (*ThumbRepository) Update

func (ir *ThumbRepository) Update(ctx context.Context, value V) error

type VisitorRepository added in v0.0.6

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

VisitorRepository saves images to database.

func NewVisitorRepository added in v0.0.6

func NewVisitorRepository(storage *sqluct.Storage) *VisitorRepository

func (*VisitorRepository) Add added in v0.0.6

func (ir *VisitorRepository) Add(ctx context.Context, value V) error

func (*VisitorRepository) Delete added in v0.0.6

func (ir *VisitorRepository) Delete(ctx context.Context, h uniq.Hash) error

func (*VisitorRepository) Ensure added in v0.0.6

func (ir *VisitorRepository) Ensure(ctx context.Context, value V, options ...uniq.EnsureOption[V]) (V, error)

func (*VisitorRepository) Exists added in v0.0.6

func (ir *VisitorRepository) Exists(ctx context.Context, hash uniq.Hash) (bool, error)

func (*VisitorRepository) FindAll added in v0.0.6

func (ir *VisitorRepository) FindAll(ctx context.Context) ([]V, error)

func (*VisitorRepository) FindByHash added in v0.0.6

func (ir *VisitorRepository) FindByHash(ctx context.Context, hash uniq.Hash) (V, error)

func (*VisitorRepository) FindByHashes added in v0.0.6

func (ir *VisitorRepository) FindByHashes(ctx context.Context, hashes ...uniq.Hash) ([]V, error)

func (*VisitorRepository) SiteVisitorEnsurer added in v0.0.6

func (ir *VisitorRepository) SiteVisitorEnsurer() uniq.Ensurer[site.Visitor]

func (*VisitorRepository) SiteVisitorFinder added in v0.0.6

func (ir *VisitorRepository) SiteVisitorFinder() uniq.Finder[site.Visitor]

func (*VisitorRepository) Update added in v0.0.6

func (ir *VisitorRepository) Update(ctx context.Context, value V) error

Directories

Path Synopsis
Package sqlite provides migrations.
Package sqlite provides migrations.
Package sqlite_stats provides migrations.
Package sqlite_stats provides migrations.
Package sqlite_thumbs provides migrations.
Package sqlite_thumbs provides migrations.

Jump to

Keyboard shortcuts

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