database

package
v1.8.1 Latest Latest
Warning

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

Go to latest
Published: Jan 20, 2026 License: AGPL-3.0 Imports: 22 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrRecordNotFound = gorm.ErrRecordNotFound
)

Functions

func Init

func Init(ctx context.Context)

Types

type DB

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

func Default

func Default() *DB

func (*DB) APIKey

func (d *DB) APIKey() repo.APIKey

APIKey implements repo.Repositories.

func (*DB) AddApiKeyQuota

func (d *DB) AddApiKeyQuota(ctx context.Context, key string, quota int) error

func (*DB) Admin

func (d *DB) Admin() repo.Admin

Admin implements repo.Repositories.

func (*DB) Artist

func (d *DB) Artist() repo.Artist

Artist implements repo.Repositories.

func (*DB) Artwork

func (d *DB) Artwork() repo.Artwork

Artwork implements repo.Repositories.

func (*DB) CachedArtwork

func (d *DB) CachedArtwork() repo.CachedArtwork

CachedArtwork implements repo.Repositories.

func (*DB) CheckDeletedByURL

func (d *DB) CheckDeletedByURL(ctx context.Context, sourceURL string) bool

func (*DB) CountArtworks

func (d *DB) CountArtworks(ctx context.Context, r18 shared.R18Type) (int64, error)

func (*DB) CreateAdmin

func (d *DB) CreateAdmin(ctx context.Context, admin *entity.Admin) (*ouid.OUID, error)

func (*DB) CreateApiKey

func (d *DB) CreateApiKey(ctx context.Context, apiKey *entity.ApiKey) (*ouid.OUID, error)

func (*DB) CreateArtist

func (d *DB) CreateArtist(ctx context.Context, artist *entity.Artist) (*ouid.OUID, error)

func (*DB) CreateArtwork

func (d *DB) CreateArtwork(ctx context.Context, artwork *entity.Artwork) (*ouid.OUID, error)

func (*DB) CreateCachedArtwork

func (d *DB) CreateCachedArtwork(ctx context.Context, data *entity.CachedArtwork) (*entity.CachedArtwork, error)

func (*DB) CreateDeletedRecord

func (d *DB) CreateDeletedRecord(ctx context.Context, deleted *entity.DeletedRecord) error

func (*DB) CreateTag

func (d *DB) CreateTag(ctx context.Context, tag *entity.Tag) (*entity.Tag, error)

func (*DB) DeleteAdminByTelegramID

func (d *DB) DeleteAdminByTelegramID(ctx context.Context, telegramID int64) error

func (*DB) DeleteApiKey

func (d *DB) DeleteApiKey(ctx context.Context, key string) error

func (*DB) DeleteArtworkByID

func (d *DB) DeleteArtworkByID(ctx context.Context, id ouid.OUID) error

func (*DB) DeleteArtworkByURL

func (d *DB) DeleteArtworkByURL(ctx context.Context, url string) error

func (*DB) DeleteCachedArtworkByID

func (d *DB) DeleteCachedArtworkByID(ctx context.Context, id ouid.OUID) error

func (*DB) DeleteCachedArtworkByURL

func (d *DB) DeleteCachedArtworkByURL(ctx context.Context, sourceUrl string) error

func (*DB) DeleteDeletedByURL

func (d *DB) DeleteDeletedByURL(ctx context.Context, sourceURL string) error

func (*DB) DeletePictureByID

func (d *DB) DeletePictureByID(ctx context.Context, id ouid.OUID) error

在数据库删除单张图片, 不做任何额外操作

func (*DB) DeleteTagByID

func (d *DB) DeleteTagByID(ctx context.Context, id ouid.OUID) error

func (*DB) DeletedRecord

func (d *DB) DeletedRecord() repo.DeletedRecord

DeletedRecord implements repo.Repositories.

func (*DB) GetAdminByTelegramID

func (d *DB) GetAdminByTelegramID(ctx context.Context, telegramID int64) (*entity.Admin, error)

func (*DB) GetAliasTagByName

func (d *DB) GetAliasTagByName(ctx context.Context, name string) (*entity.TagAlias, error)

func (*DB) GetApiKeyByKey

func (d *DB) GetApiKeyByKey(ctx context.Context, key string) (*entity.ApiKey, error)

func (*DB) GetArtistByID

func (d *DB) GetArtistByID(ctx context.Context, id ouid.OUID) (*entity.Artist, error)

func (*DB) GetArtistByUID

func (d *DB) GetArtistByUID(ctx context.Context, uid string, source shared.SourceType) (*entity.Artist, error)

func (*DB) GetArtworkByID

func (d *DB) GetArtworkByID(ctx context.Context, id ouid.OUID) (*entity.Artwork, error)

func (*DB) GetArtworkByURL

func (d *DB) GetArtworkByURL(ctx context.Context, url string) (*entity.Artwork, error)

func (*DB) GetArtworksByIDs

func (d *DB) GetArtworksByIDs(ctx context.Context, ids []ouid.OUID) ([]*entity.Artwork, error)

func (*DB) GetCachedArtworkByID

func (d *DB) GetCachedArtworkByID(ctx context.Context, id ouid.OUID) (*entity.CachedArtwork, error)

GetCachedArtworkByID implements repo.CachedArtwork.

func (*DB) GetCachedArtworkByURL

func (d *DB) GetCachedArtworkByURL(ctx context.Context, sourceUrl string) (*entity.CachedArtwork, error)

func (*DB) GetDeletedByURL

func (d *DB) GetDeletedByURL(ctx context.Context, sourceURL string) (*entity.DeletedRecord, error)

func (*DB) GetPictureByID

func (d *DB) GetPictureByID(ctx context.Context, id ouid.OUID) (*entity.Picture, error)

func (*DB) GetTagByID

func (d *DB) GetTagByID(ctx context.Context, id ouid.OUID) (*entity.Tag, error)

func (*DB) GetTagByName

func (d *DB) GetTagByName(ctx context.Context, name string) (*entity.Tag, error)

func (*DB) GetTagByNameWithAlias

func (d *DB) GetTagByNameWithAlias(ctx context.Context, name string) (*entity.Tag, error)

func (*DB) GetUgoiraByID

func (d *DB) GetUgoiraByID(ctx context.Context, id ouid.OUID) (*entity.UgoiraMeta, error)

func (*DB) GetVideoByID added in v1.5.0

func (d *DB) GetVideoByID(ctx context.Context, id ouid.OUID) (*entity.Video, error)

func (*DB) IncreaseApiKeyUsed

func (d *DB) IncreaseApiKeyUsed(ctx context.Context, key string) error

func (*DB) ListAdmins

func (d *DB) ListAdmins(ctx context.Context) ([]entity.Admin, error)

func (*DB) MigrateTagAlias

func (d *DB) MigrateTagAlias(ctx context.Context, aliasTagID, targetTagID ouid.OUID) ([]ouid.OUID, error)

MigrateTagAlias 迁移别名标签到目标标签,并删除别名标签

返回受影响的 artwork ids

func (*DB) Picture

func (d *DB) Picture() repo.Picture

Picture implements repo.Repositories.

func (*DB) QueryArtworks

func (d *DB) QueryArtworks(ctx context.Context, que query.ArtworksDB) ([]*entity.Artwork, error)

func (*DB) QueryPicturesByPhash

func (d *DB) QueryPicturesByPhash(ctx context.Context, que query.PicturesPhash) ([]*entity.Picture, error)

func (*DB) RandomPictures

func (d *DB) RandomPictures(ctx context.Context, limit int) ([]*entity.Picture, error)

RandomPictures implements repo.Picture.

func (*DB) RandomTags

func (d *DB) RandomTags(ctx context.Context, limit int) ([]*entity.Tag, error)

func (*DB) ReorderArtworkPicturesByID

func (d *DB) ReorderArtworkPicturesByID(ctx context.Context, artworkID ouid.OUID) error

func (*DB) ResetPostingCachedArtworkStatus

func (d *DB) ResetPostingCachedArtworkStatus(ctx context.Context) error

func (*DB) SaveCachedArtwork

func (d *DB) SaveCachedArtwork(ctx context.Context, artwork *entity.CachedArtwork) (*entity.CachedArtwork, error)

func (*DB) SavePicture

func (d *DB) SavePicture(ctx context.Context, pic *entity.Picture) error

func (*DB) Tag

func (d *DB) Tag() repo.Tag

Tag implements repo.Repositories.

func (*DB) Transaction

func (d *DB) Transaction(ctx context.Context, fn func(repos repo.Repositories) error) error

Transaction implements repo.Repositories.

func (*DB) Ugoira

func (d *DB) Ugoira() repo.Ugoira

func (*DB) UpdateAdminPermissions

func (d *DB) UpdateAdminPermissions(ctx context.Context, id ouid.OUID, permissions []shared.Permission) error

func (*DB) UpdateArtist

func (d *DB) UpdateArtist(ctx context.Context, patch *entity.Artist) error

func (*DB) UpdateArtwork

func (d *DB) UpdateArtwork(ctx context.Context, patch *entity.Artwork) error

UpdateArtwork updates non-zero fields in the patch.

func (*DB) UpdateArtworkByMap

func (d *DB) UpdateArtworkByMap(ctx context.Context, id ouid.OUID, patch map[string]any) error

UpdateArtworkByMap updates all given fields in the patch map.

func (*DB) UpdateArtworkPictures

func (d *DB) UpdateArtworkPictures(ctx context.Context, id ouid.OUID, pics []*entity.Picture) error

func (*DB) UpdateArtworkTags

func (d *DB) UpdateArtworkTags(ctx context.Context, id ouid.OUID, tags []*entity.Tag) error

func (*DB) UpdateCachedArtworkStatusByURL

func (d *DB) UpdateCachedArtworkStatusByURL(ctx context.Context, sourceUrl string, status shared.ArtworkStatus) error

func (*DB) UpdatePictureTelegramInfoByID

func (d *DB) UpdatePictureTelegramInfoByID(ctx context.Context, id ouid.OUID, tgInfo *shared.TelegramInfo) (*entity.Picture, error)

func (*DB) UpdateTagAlias

func (d *DB) UpdateTagAlias(ctx context.Context, id ouid.OUID, alias []*entity.TagAlias) error

func (*DB) UpdateUgoiraTelegramInfoByID

func (d *DB) UpdateUgoiraTelegramInfoByID(ctx context.Context, id ouid.OUID, tgInfo *shared.TelegramInfo) (*entity.UgoiraMeta, error)

UpdateUgoiraTelegramInfoByID implements repo.Ugoira.

func (*DB) UpdateVideoTelegramInfoByID added in v1.5.0

func (d *DB) UpdateVideoTelegramInfoByID(ctx context.Context, id ouid.OUID, tgInfo *shared.TelegramInfo) (*entity.Video, error)

UpdateVideoTelegramInfoByID implements repo.Video.

func (*DB) Video added in v1.5.0

func (d *DB) Video() repo.Video

Video implements repo.Repositories.

Jump to

Keyboard shortcuts

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