dao

package
v0.73.0 Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Client *mongo.Client

Functions

func AddAliasToAllTags added in v0.65.0

func AddAliasToAllTags(ctx context.Context) error

func AddApiKeyQuota added in v0.69.0

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

func AddLikeCountToArtwork

func AddLikeCountToArtwork(ctx context.Context) error

func CheckDeletedByURL

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

func CleanPostingCachedArtwork

func CleanPostingCachedArtwork(ctx context.Context) (*mongo.DeleteResult, error)

func CleanTag added in v0.67.0

func CleanTag(ctx context.Context, regex string) error

func ConvertArtistUIDToString

func ConvertArtistUIDToString(ctx context.Context) error

func CreateAdmin

func CreateAdmin(ctx context.Context, admin *types.AdminModel) (*mongo.InsertOneResult, error)

func CreateApiKey added in v0.69.0

func CreateApiKey(ctx context.Context, apiKey *types.ApiKeyModel) (*mongo.InsertOneResult, error)

func CreateArtist

func CreateArtist(ctx context.Context, artist *types.ArtistModel) (*mongo.InsertOneResult, error)

func CreateArtwork

func CreateArtwork(ctx context.Context, artwork *types.ArtworkModel) (*mongo.InsertOneResult, error)

func CreateCachedArtwork

func CreateCachedArtwork(ctx context.Context, artwork *types.Artwork, status types.ArtworkStatus) (*mongo.InsertOneResult, error)

func CreateCallbackData

func CreateCallbackData(ctx context.Context, data string) (*types.CallbackDataModel, error)

func CreateDeleted

func CreateDeleted(ctx context.Context, deleted *types.DeletedModel) (*mongo.InsertOneResult, error)

func CreateFavorite

func CreateFavorite(ctx context.Context, userID, artworkID primitive.ObjectID) (*mongo.InsertOneResult, error)

func CreateLike

func CreateLike(ctx context.Context, like *types.LikeModel) (*mongo.InsertOneResult, error)

func CreatePicture

func CreatePicture(ctx context.Context, picture *types.PictureModel) (*mongo.InsertOneResult, error)

func CreatePictures

func CreatePictures(ctx context.Context, pictures []*types.PictureModel) (*mongo.InsertManyResult, error)

func CreateSuperAdminByUserID

func CreateSuperAdminByUserID(ctx context.Context, userID int64, grant int64) (*mongo.InsertOneResult, error)

func CreateTag

func CreateTag(ctx context.Context, tag *types.TagModel) (*mongo.InsertOneResult, error)

func CreateTags

func CreateTags(ctx context.Context, tags []*types.TagModel) (*mongo.InsertManyResult, error)

func CreateUnauthUser

func CreateUnauthUser(ctx context.Context, user *types.UnauthUserModel) (*mongo.InsertOneResult, error)

func CreateUser

func CreateUser(ctx context.Context, user *types.UserModel) (*mongo.InsertOneResult, error)

func DeleteAdminByUserID

func DeleteAdminByUserID(ctx context.Context, userID int64) (*mongo.DeleteResult, error)

func DeleteApiKey added in v0.69.0

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

func DeleteArtworkByID

func DeleteArtworkByID(ctx context.Context, id primitive.ObjectID) (*mongo.DeleteResult, error)

func DeleteCachedArtworkByURL added in v0.60.0

func DeleteCachedArtworkByURL(ctx context.Context, url string) (*mongo.DeleteResult, error)

func DeleteDeletedByURL

func DeleteDeletedByURL(ctx context.Context, sourceURL string) (*mongo.DeleteResult, error)

func DeleteEtcData

func DeleteEtcData(ctx context.Context, key string) (*mongo.DeleteResult, error)

func DeleteFavorite

func DeleteFavorite(ctx context.Context, userID, artworkID primitive.ObjectID) (*mongo.DeleteResult, error)

func DeletePictureByID

func DeletePictureByID(ctx context.Context, id primitive.ObjectID) (*mongo.DeleteResult, error)

func DeletePicturesByArtworkID

func DeletePicturesByArtworkID(ctx context.Context, artworkID primitive.ObjectID) (*mongo.DeleteResult, error)

func DeleteTagByID added in v0.65.0

func DeleteTagByID(ctx context.Context, id primitive.ObjectID) (*mongo.DeleteResult, error)

func DeleteUnauthUser

func DeleteUnauthUser(ctx context.Context, id primitive.ObjectID) (*mongo.DeleteResult, error)

func GetAdminByUserID

func GetAdminByUserID(ctx context.Context, userID int64) (*types.AdminModel, error)

func GetAdmins

func GetAdmins(ctx context.Context) ([]types.AdminModel, error)

func GetApiKeyByKey added in v0.69.0

func GetApiKeyByKey(ctx context.Context, key string) (*types.ApiKeyModel, error)

func GetArtistByID

func GetArtistByID(ctx context.Context, id primitive.ObjectID) (*types.ArtistModel, error)

func GetArtistByUID

func GetArtistByUID(ctx context.Context, uid string, sourceType types.SourceType) (*types.ArtistModel, error)

func GetArtistByUserName

func GetArtistByUserName(ctx context.Context, username string, sourceType types.SourceType) (*types.ArtistModel, error)

func GetArtistCount

func GetArtistCount(ctx context.Context) (int64, error)

func GetArtworkByID

func GetArtworkByID(ctx context.Context, id primitive.ObjectID) (*types.ArtworkModel, error)

func GetArtworkByURL

func GetArtworkByURL(ctx context.Context, url string) (*types.ArtworkModel, error)

func GetArtworkCount

func GetArtworkCount(ctx context.Context, r18 types.R18Type) (int64, error)

func GetArtworkCountByArtistID

func GetArtworkCountByArtistID(ctx context.Context, artistID primitive.ObjectID, r18 types.R18Type) (int64, error)

func GetArtworksByArtistID

func GetArtworksByArtistID(ctx context.Context, artistID primitive.ObjectID, r18 types.R18Type, page, pageSize int64) ([]*types.ArtworkModel, error)

func GetArtworksByR18

func GetArtworksByR18(ctx context.Context, r18 types.R18Type, limit int) ([]*types.ArtworkModel, error)

func GetArtworksByTags

func GetArtworksByTags(ctx context.Context, tags [][]primitive.ObjectID, r18 types.R18Type, page, pageSize int64) ([]*types.ArtworkModel, error)

func GetCachedArtworkByURL

func GetCachedArtworkByURL(ctx context.Context, url string) (*types.CachedArtworksModel, error)

func GetCallbackDataByID

func GetCallbackDataByID(ctx context.Context, id primitive.ObjectID) (*types.CallbackDataModel, error)

func GetCollection added in v0.65.0

func GetCollection(name string) *mongo.Collection

func GetDeletedByURL

func GetDeletedByURL(ctx context.Context, sourceURL string) (*types.DeletedModel, error)

func GetEtcData

func GetEtcData(ctx context.Context, key string) (bson.M, error)

func GetFavorite

func GetFavorite(ctx context.Context, userID, artworkID primitive.ObjectID) (*types.FavoriteModel, error)

func GetLatestArtworks

func GetLatestArtworks(ctx context.Context, r18 types.R18Type, page, pageSize int64) ([]*types.ArtworkModel, error)

func GetLike

func GetLike(ctx context.Context, userID, artworkID primitive.ObjectID) (*types.LikeModel, error)

func GetNoHashPictures

func GetNoHashPictures(ctx context.Context) ([]*types.PictureModel, error)

func GetNoRegularAndThumbPictures

func GetNoRegularAndThumbPictures(ctx context.Context) ([]*types.PictureModel, error)

func GetPictureByID

func GetPictureByID(ctx context.Context, id primitive.ObjectID) (*types.PictureModel, error)

func GetPictureByMessageID deprecated

func GetPictureByMessageID(ctx context.Context, messageID int) (*types.PictureModel, error)

Deprecated: MessageID 现在可能为 0

func GetPictureByOriginal

func GetPictureByOriginal(ctx context.Context, original string) (*types.PictureModel, error)

func GetPictureCount

func GetPictureCount(ctx context.Context) (int64, error)

func GetPicturesByHash

func GetPicturesByHash(ctx context.Context, hash string) ([]*types.PictureModel, error)

func GetPicturesByHashHammingDistance

func GetPicturesByHashHammingDistance(ctx context.Context, hashStr string, distance int) ([]*types.PictureModel, error)

全库遍历搜索

func GetRandomPictures added in v0.60.0

func GetRandomPictures(ctx context.Context, limit int) ([]*types.PictureModel, error)

func GetRandomTags

func GetRandomTags(ctx context.Context, limit int) ([]*types.TagModel, error)

func GetTagByAlias added in v0.67.1

func GetTagByAlias(ctx context.Context, alias string) (*types.TagModel, error)

func GetTagByID

func GetTagByID(ctx context.Context, id primitive.ObjectID) (*types.TagModel, error)

func GetTagByName

func GetTagByName(ctx context.Context, name string) (*types.TagModel, error)

func GetTagByNameWithAlias added in v0.65.0

func GetTagByNameWithAlias(ctx context.Context, name string) (*types.TagModel, error)

func GetTagCount

func GetTagCount(ctx context.Context) (int64, error)

func GetUnauthUserByID

func GetUnauthUserByID(ctx context.Context, id primitive.ObjectID) (*types.UnauthUserModel, error)

func GetUnauthUserByUsername

func GetUnauthUserByUsername(ctx context.Context, username string) (*types.UnauthUserModel, error)

func GetUserByEmail

func GetUserByEmail(ctx context.Context, email string) (*types.UserModel, error)

func GetUserByID

func GetUserByID(ctx context.Context, id primitive.ObjectID) (*types.UserModel, error)

func GetUserByTelegramID

func GetUserByTelegramID(ctx context.Context, telegramID int64) (*types.UserModel, error)

func GetUserByUsername

func GetUserByUsername(ctx context.Context, username string) (*types.UserModel, error)

func IncreaseApiKeyUsed added in v0.69.0

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

func IncrementArtworkLikeCountByID

func IncrementArtworkLikeCountByID(ctx context.Context, id primitive.ObjectID) (*mongo.UpdateResult, error)

func InitDB

func InitDB(ctx context.Context)

func MigrateStorageInfo

func MigrateStorageInfo(ctx context.Context) error

func QueryArtistsByName

func QueryArtistsByName(ctx context.Context, name string) ([]*types.ArtistModel, error)

func QueryArtistsByUserName

func QueryArtistsByUserName(ctx context.Context, username string) ([]*types.ArtistModel, error)

func QueryArtworksByTexts

func QueryArtworksByTexts(ctx context.Context, texts [][]string, r18 types.R18Type, limit int) ([]*types.ArtworkModel, error)

func QueryArtworksByTextsPage

func QueryArtworksByTextsPage(ctx context.Context, texts [][]string, r18 types.R18Type, page, pageSize int64) ([]*types.ArtworkModel, error)

func QueryTagsByName

func QueryTagsByName(ctx context.Context, name string) ([]*types.TagModel, error)

func RemoveTagAliasByID added in v0.65.0

func RemoveTagAliasByID(ctx context.Context, id primitive.ObjectID, alias []string) error

func SetEtcData

func SetEtcData(ctx context.Context, key string, value any) (*mongo.UpdateResult, error)

func TidyArtist

func TidyArtist(ctx context.Context) error

func TidyTag added in v0.66.0

func TidyTag(ctx context.Context) error

func UpdateAdmin

func UpdateAdmin(ctx context.Context, admin *types.AdminModel) (*mongo.UpdateResult, error)

func UpdateArtist

func UpdateArtist(ctx context.Context, artist *types.ArtistModel) (*mongo.UpdateResult, error)

func UpdateArtworkPicturesByID

func UpdateArtworkPicturesByID(ctx context.Context, id primitive.ObjectID, pictures []primitive.ObjectID) (*mongo.UpdateResult, error)

func UpdateArtworkR18ByID

func UpdateArtworkR18ByID(ctx context.Context, id primitive.ObjectID, r18 bool) (*mongo.UpdateResult, error)

func UpdateArtworkTagsByID

func UpdateArtworkTagsByID(ctx context.Context, id primitive.ObjectID, tags []primitive.ObjectID) (*mongo.UpdateResult, error)

func UpdateArtworkTitleByID

func UpdateArtworkTitleByID(ctx context.Context, id primitive.ObjectID, title string) (*mongo.UpdateResult, error)

func UpdateCachedArtwork

func UpdateCachedArtwork(ctx context.Context, artwork *types.CachedArtworksModel) (*mongo.UpdateResult, error)

func UpdateCachedArtworkStatusByURL

func UpdateCachedArtworkStatusByURL(ctx context.Context, url string, status types.ArtworkStatus) (*mongo.UpdateResult, error)

func UpdatePictureByID added in v0.60.0

func UpdatePictureByID(ctx context.Context, id primitive.ObjectID, picture *types.PictureModel) (*mongo.UpdateResult, error)

func UpdatePictureHashByID added in v0.60.0

func UpdatePictureHashByID(ctx context.Context, id primitive.ObjectID, hash string) (*mongo.UpdateResult, error)

func UpdatePictureIndexByID

func UpdatePictureIndexByID(ctx context.Context, id primitive.ObjectID, index uint) (*mongo.UpdateResult, error)

func UpdatePictureSizeByID

func UpdatePictureSizeByID(ctx context.Context, id primitive.ObjectID, width, height int) (*mongo.UpdateResult, error)

func UpdatePictureStorageInfoByID

func UpdatePictureStorageInfoByID(ctx context.Context, id primitive.ObjectID, storageInfo *types.StorageInfo) (*mongo.UpdateResult, error)

func UpdatePictureTelegramInfoByID

func UpdatePictureTelegramInfoByID(ctx context.Context, id primitive.ObjectID, telegramInfo *types.TelegramInfo) (*mongo.UpdateResult, error)

func UpdateTagAliasByID added in v0.65.0

func UpdateTagAliasByID(ctx context.Context, id primitive.ObjectID, alias []string) error

func UpdateUserSettings

func UpdateUserSettings(ctx context.Context, id primitive.ObjectID, settings *types.UserSettings) (*mongo.UpdateResult, error)

Types

This section is empty.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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