db

package
v0.5.1 Latest Latest
Warning

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

Go to latest
Published: Apr 25, 2024 License: AGPL-3.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

View Source
const (
	GuestUsername = "guest"
	GuestUserID   = "00000000000000000000000000000001"
)
View Source
const CurrentVersion = "0.0.6"

Variables

This section is empty.

Functions

func AddAdmin

func AddAdmin(u *model.User) error

func AddAdminByID

func AddAdminByID(userID string) error

func AddMemberPermissions added in v0.5.0

func AddMemberPermissions(roomID string, userID string, permission model.RoomMemberPermission) error

func AddRoot

func AddRoot(u *model.User) error

func AddRootByID

func AddRootByID(userID string) error

func BanUser

func BanUser(u *model.User) error

func BanUserByID

func BanUserByID(userID string) error

func BindEmail added in v0.4.5

func BindEmail(id string, email string) error

func BindProvider

func BindProvider(uid string, p provider.OAuth2Provider, puid string) error

func Close

func Close()

func CreateMovie

func CreateMovie(movie *model.Movie) error

func CreateMovies

func CreateMovies(movies []*model.Movie) error

func CreateOrLoadUser

func CreateOrLoadUser(username string, password string, conf ...CreateUserConfig) (*model.User, error)

func CreateOrLoadUserWithEmail added in v0.4.5

func CreateOrLoadUserWithEmail(username, password, email string, conf ...CreateUserConfig) (*model.User, error)

func CreateOrLoadUserWithHashedPassword

func CreateOrLoadUserWithHashedPassword(username string, hashedPassword []byte, conf ...CreateUserConfig) (*model.User, error)

func CreateOrLoadUserWithProvider

func CreateOrLoadUserWithProvider(username, password string, p provider.OAuth2Provider, puid string, conf ...CreateUserConfig) (*model.User, error)

只有当provider和puid没有找到对应的user时才会创建

func CreateOrSaveAlistVendor added in v0.3.1

func CreateOrSaveAlistVendor(vendorInfo *model.AlistVendor) (*model.AlistVendor, error)

func CreateOrSaveBilibiliVendor added in v0.3.1

func CreateOrSaveBilibiliVendor(vendorInfo *model.BilibiliVendor) (*model.BilibiliVendor, error)

func CreateOrSaveEmbyVendor added in v0.3.1

func CreateOrSaveEmbyVendor(vendorInfo *model.EmbyVendor) (*model.EmbyVendor, error)

func CreateOrSaveVendorBackend added in v0.3.1

func CreateOrSaveVendorBackend(backend *model.VendorBackend) (*model.VendorBackend, error)

func CreateRoom

func CreateRoom(name, password string, maxCount int64, conf ...CreateRoomConfig) (*model.Room, error)

if maxCount is 0, it will be ignored

func CreateUser

func CreateUser(username string, password string, conf ...CreateUserConfig) (*model.User, error)

func CreateUserWithEmail added in v0.4.5

func CreateUserWithEmail(username, password, email string, conf ...CreateUserConfig) (*model.User, error)

func CreateUserWithHashedPassword

func CreateUserWithHashedPassword(username string, hashedPassword []byte, conf ...CreateUserConfig) (*model.User, error)

func CreateVendorBackend added in v0.3.1

func CreateVendorBackend(backend *model.VendorBackend) error

func DB

func DB() *gorm.DB

func DeleteAlistVendor added in v0.3.1

func DeleteAlistVendor(userID, serverID string) error

func DeleteBilibiliVendor added in v0.3.1

func DeleteBilibiliVendor(userID string) error

func DeleteEmbyVendor added in v0.3.1

func DeleteEmbyVendor(userID, serverID string) error

func DeleteMovieByID

func DeleteMovieByID(roomID, id string) error

func DeleteMoviesByID added in v0.5.0

func DeleteMoviesByID(roomID string, ids []string) error

func DeleteMoviesByRoomID

func DeleteMoviesByRoomID(roomID string) error

func DeleteRoomByID

func DeleteRoomByID(roomID string) error

func DeleteSettingItem

func DeleteSettingItem(item *model.Setting) error

func DeleteSettingItemByName

func DeleteSettingItemByName(name string) error

func DeleteUserByID

func DeleteUserByID(userID string) error

func DeleteVendorBackend added in v0.3.1

func DeleteVendorBackend(endpoint string) error

func DeleteVendorBackends added in v0.3.1

func DeleteVendorBackends(endpoints []string) error

func DisableVendorBackend added in v0.3.1

func DisableVendorBackend(endpoint string) error

func DisableVendorBackends added in v0.3.1

func DisableVendorBackends(endpoints []string) error

func EnableVendorBackend added in v0.3.1

func EnableVendorBackend(endpoint string) error

func EnableVendorBackends added in v0.3.1

func EnableVendorBackends(endpoints []string) error

func FirstOrCreateRoomMemberRelation added in v0.5.0

func FirstOrCreateRoomMemberRelation(roomID, userID string, conf ...CreateRoomMemberRelationConfig) (*model.RoomMember, error)

func FirstOrCreateSettingItemValue

func FirstOrCreateSettingItemValue(s *model.Setting) error

func GerUsersIDByIDLike

func GerUsersIDByIDLike(id string, scopes ...func(*gorm.DB) *gorm.DB) ([]string, error)

func GerUsersIDByUsernameLike

func GerUsersIDByUsernameLike(username string, scopes ...func(*gorm.DB) *gorm.DB) ([]string, error)

func GetAdmins

func GetAdmins() ([]*model.User, error)

func GetAlistVendor added in v0.3.1

func GetAlistVendor(userID, serverID string) (*model.AlistVendor, error)

func GetAlistVendors added in v0.3.2

func GetAlistVendors(userID string, scopes ...func(*gorm.DB) *gorm.DB) ([]*model.AlistVendor, error)

func GetAlistVendorsCount added in v0.3.2

func GetAlistVendorsCount(userID string, scopes ...func(*gorm.DB) *gorm.DB) (int64, error)

func GetAllMoviesByRoomID

func GetAllMoviesByRoomID(roomID string) []*model.Movie

func GetAllRooms

func GetAllRooms(scopes ...func(*gorm.DB) *gorm.DB) ([]*model.Room, error)

func GetAllRoomsAndCreator

func GetAllRoomsAndCreator(scopes ...func(*gorm.DB) *gorm.DB) ([]*model.Room, error)

func GetAllRoomsByUserID

func GetAllRoomsByUserID(userID string) ([]*model.Room, error)

func GetAllRoomsCount

func GetAllRoomsCount(scopes ...func(*gorm.DB) *gorm.DB) (int64, error)

func GetAllUserCount

func GetAllUserCount(scopes ...func(*gorm.DB) *gorm.DB) (int64, error)

func GetAllUsers

func GetAllUsers(scopes ...func(*gorm.DB) *gorm.DB) ([]*model.User, error)

func GetAllVendorBackend added in v0.3.1

func GetAllVendorBackend() ([]*model.VendorBackend, error)

func GetBilibiliVendor added in v0.3.1

func GetBilibiliVendor(userID string) (*model.BilibiliVendor, error)

func GetBindProviders

func GetBindProviders(uid string) ([]*model.UserProvider, error)

func GetEmbyFirstVendor added in v0.3.2

func GetEmbyFirstVendor(userID string) (*model.EmbyVendor, error)

func GetEmbyVendor added in v0.3.1

func GetEmbyVendor(userID, serverID string) (*model.EmbyVendor, error)

func GetEmbyVendors added in v0.3.2

func GetEmbyVendors(userID string, scopes ...func(*gorm.DB) *gorm.DB) ([]*model.EmbyVendor, error)

func GetEmbyVendorsCount added in v0.3.2

func GetEmbyVendorsCount(userID string, scopes ...func(*gorm.DB) *gorm.DB) (int64, error)

func GetOrCreateRoomSettings added in v0.5.0

func GetOrCreateRoomSettings(roomID string) (*model.RoomSettings, error)

func GetProviderUserID

func GetProviderUserID(p provider.OAuth2Provider, puid string) (string, error)

func GetRoomByID

func GetRoomByID(id string) (*model.Room, error)

func GetRoomMember added in v0.5.0

func GetRoomMember(roomID, userID string) (*model.RoomMember, error)

func GetRoots

func GetRoots() []*model.User

func GetSettingItemByName

func GetSettingItemByName(name string) (*model.Setting, error)

func GetSettingItemValue

func GetSettingItemValue(name string) (string, error)

func GetSettingItems

func GetSettingItems() ([]*model.Setting, error)

func GetSettingItemsToMap added in v0.3.2

func GetSettingItemsToMap() (map[string]*model.Setting, error)

func GetUserByEmail added in v0.4.5

func GetUserByEmail(email string) (*model.User, error)

func GetUserByID

func GetUserByID(id string) (*model.User, error)

func GetUserByIDOrUsernameLike

func GetUserByIDOrUsernameLike(idOrUsername string, scopes ...func(*gorm.DB) *gorm.DB) ([]*model.User, error)

func GetUserByProvider

func GetUserByProvider(p provider.OAuth2Provider, puid string) (*model.User, error)

func GetUserByUsername

func GetUserByUsername(username string) (*model.User, error)

func GetUserByUsernameLike

func GetUserByUsernameLike(username string, scopes ...func(*gorm.DB) *gorm.DB) ([]*model.User, error)

func GetVendorBackend added in v0.3.1

func GetVendorBackend(endpoint string) (*model.VendorBackend, error)

func HandleNotFound added in v0.3.1

func HandleNotFound(err error, errMsg ...string) error

func Init

func Init(d *gorm.DB, t conf.DatabaseType) error

func LoadAndDeleteMovieByID

func LoadAndDeleteMovieByID(roomID, id string, columns ...clause.Column) (*model.Movie, error)

func LoadAndDeleteMoviesByRoomID

func LoadAndDeleteMoviesByRoomID(roomID string, columns ...clause.Column) ([]*model.Movie, error)

func LoadAndDeleteUserByID

func LoadAndDeleteUserByID(userID string, columns ...clause.Column) (*model.User, error)

func OrderByAsc

func OrderByAsc(column string) func(db *gorm.DB) *gorm.DB

func OrderByCreatedAtAsc

func OrderByCreatedAtAsc(db *gorm.DB) *gorm.DB

func OrderByCreatedAtDesc

func OrderByCreatedAtDesc(db *gorm.DB) *gorm.DB

func OrderByDesc

func OrderByDesc(column string) func(db *gorm.DB) *gorm.DB

func OrderByIDAsc

func OrderByIDAsc(db *gorm.DB) *gorm.DB

func OrderByIDDesc

func OrderByIDDesc(db *gorm.DB) *gorm.DB

func OrderByUsersCreatedAtAsc added in v0.5.0

func OrderByUsersCreatedAtAsc(db *gorm.DB) *gorm.DB

func OrderByUsersCreatedAtDesc added in v0.5.0

func OrderByUsersCreatedAtDesc(db *gorm.DB) *gorm.DB

func Paginate

func Paginate(page, pageSize int) func(db *gorm.DB) *gorm.DB

func PreloadRoomMembers added in v0.5.0

func PreloadRoomMembers(scopes ...func(*gorm.DB) *gorm.DB) func(db *gorm.DB) *gorm.DB

func PreloadUserProviders

func PreloadUserProviders(scopes ...func(*gorm.DB) *gorm.DB) func(db *gorm.DB) *gorm.DB

func RemoveAdmin

func RemoveAdmin(u *model.User) error

func RemoveAdminByID

func RemoveAdminByID(userID string) error

func RemoveMemberPermissions added in v0.5.0

func RemoveMemberPermissions(roomID string, userID string, permission model.RoomMemberPermission) error

func RemoveRoot

func RemoveRoot(u *model.User) error

func RemoveRootByID

func RemoveRootByID(userID string) error

func RoomAddAdminPermissions added in v0.5.0

func RoomAddAdminPermissions(roomID, userID string, permissions model.RoomAdminPermission) error

func RoomApprovePendingMember added in v0.5.0

func RoomApprovePendingMember(roomID, userID string) error

func RoomBanMember added in v0.5.0

func RoomBanMember(roomID, userID string) error

func RoomRemoveAdminPermissions added in v0.5.0

func RoomRemoveAdminPermissions(roomID, userID string, permissions model.RoomAdminPermission) error

func RoomSetAdmin added in v0.5.0

func RoomSetAdmin(roomID, userID string, permissions model.RoomAdminPermission) error

func RoomSetAdminPermissions added in v0.5.0

func RoomSetAdminPermissions(roomID, userID string, permissions model.RoomAdminPermission) error

func RoomSetMember added in v0.5.0

func RoomSetMember(roomID, userID string, permissions model.RoomMemberPermission) error

func RoomUnbanMember added in v0.5.0

func RoomUnbanMember(roomID, userID string) error

func SaveMovie

func SaveMovie(movie *model.Movie, columns ...clause.Column) error

func SaveRoomSettings

func SaveRoomSettings(roomID string, settings *model.RoomSettings) error

func SaveSettingItem

func SaveSettingItem(item *model.Setting) error

func SaveUser

func SaveUser(u *model.User) error

func SaveVendorBackend added in v0.3.1

func SaveVendorBackend(backend *model.VendorBackend) error

func Select

func Select(columns ...string) func(db *gorm.DB) *gorm.DB

func SetAdminRoleByID added in v0.5.0

func SetAdminRoleByID(userID string) error

func SetMemberPermissions added in v0.5.0

func SetMemberPermissions(roomID string, userID string, permission model.RoomMemberPermission) error

func SetRoomHashedPassword

func SetRoomHashedPassword(roomID string, hashedPassword []byte) error

func SetRoomPassword

func SetRoomPassword(roomID, password string) error

func SetRoomStatus

func SetRoomStatus(roomID string, status model.RoomStatus) error

func SetRoomStatusByCreator

func SetRoomStatusByCreator(userID string, status model.RoomStatus) error

func SetRootRoleByID added in v0.5.0

func SetRootRoleByID(userID string) error

func SetUserHashedPassword

func SetUserHashedPassword(id string, hashedPassword []byte) error

func SetUserRoleByID added in v0.5.0

func SetUserRoleByID(userID string) error

func SetUsernameByID

func SetUsernameByID(userID string, username string) error

func SwapMoviePositions

func SwapMoviePositions(roomID, movie1ID, movie2ID string) (err error)

func Transactional added in v0.3.1

func Transactional(txFunc func(*gorm.DB) error) (err error)

func UnBindProvider

func UnBindProvider(uid string, p provider.OAuth2Provider) error

当用户是通过provider注册的时候,则最少保留一个provider,否则禁止解除绑定

func UnbanUser

func UnbanUser(u *model.User) error

func UnbanUserByID

func UnbanUserByID(userID string) error

func UnbindEmail added in v0.4.5

func UnbindEmail(uid string) error

func UpdateMovie

func UpdateMovie(movie *model.Movie, columns ...clause.Column) error

func UpdateRoomSettings added in v0.5.0

func UpdateRoomSettings(roomID string, settings map[string]interface{}) (*model.RoomSettings, error)

func UpdateSettingItemValue

func UpdateSettingItemValue(name, value string) error

func UpgradeDatabase added in v0.3.2

func UpgradeDatabase() error

func WhereCreatorID

func WhereCreatorID(creatorID string) func(db *gorm.DB) *gorm.DB

func WhereCreatorIDIn

func WhereCreatorIDIn(ids []string) func(db *gorm.DB) *gorm.DB

func WhereEqual

func WhereEqual(column string, value interface{}) func(db *gorm.DB) *gorm.DB

column cannot be a user parameter

func WhereIDIn

func WhereIDIn(ids []string) func(db *gorm.DB) *gorm.DB

func WhereIDLike

func WhereIDLike(id string) func(db *gorm.DB) *gorm.DB

func WhereLike

func WhereLike(column string, value string) func(db *gorm.DB) *gorm.DB

column cannot be a user parameter

func WhereRole

func WhereRole(role model.Role) func(db *gorm.DB) *gorm.DB

func WhereRoomID

func WhereRoomID(roomID string) func(db *gorm.DB) *gorm.DB

func WhereRoomMemberRole added in v0.5.0

func WhereRoomMemberRole(role model.RoomMemberRole) func(db *gorm.DB) *gorm.DB

func WhereRoomMemberStatus added in v0.5.0

func WhereRoomMemberStatus(status model.RoomMemberStatus) func(db *gorm.DB) *gorm.DB

func WhereRoomNameLike

func WhereRoomNameLike(name string) func(db *gorm.DB) *gorm.DB

func WhereRoomNameLikeOrCreatorInOrIDLike

func WhereRoomNameLikeOrCreatorInOrIDLike(name string, ids []string, id string) func(db *gorm.DB) *gorm.DB

func WhereRoomNameLikeOrCreatorInOrRoomsIDLike added in v0.5.0

func WhereRoomNameLikeOrCreatorInOrRoomsIDLike(name string, ids []string, id string) func(db *gorm.DB) *gorm.DB

func WhereRoomNameLikeOrIDLike

func WhereRoomNameLikeOrIDLike(name string, id string) func(db *gorm.DB) *gorm.DB

func WhereRoomSettingWithoutHidden

func WhereRoomSettingWithoutHidden() func(db *gorm.DB) *gorm.DB

func WhereRoomsIDLike added in v0.5.0

func WhereRoomsIDLike(id string) func(db *gorm.DB) *gorm.DB

func WhereStatus

func WhereStatus(status model.RoomStatus) func(db *gorm.DB) *gorm.DB

func WhereUserID

func WhereUserID(userID string) func(db *gorm.DB) *gorm.DB

func WhereUsernameLike

func WhereUsernameLike(name string) func(db *gorm.DB) *gorm.DB

func WhereUsernameLikeOrIDIn

func WhereUsernameLikeOrIDIn(name string, ids []string) func(db *gorm.DB) *gorm.DB

func WithUser

func WithUser(db *gorm.DB) *gorm.DB

Types

type CreateRoomConfig

type CreateRoomConfig func(r *model.Room)

func WithCreator

func WithCreator(creator *model.User) CreateRoomConfig

func WithRelations

func WithRelations(relations []*model.RoomMember) CreateRoomConfig

func WithSetting

func WithSetting(setting *model.RoomSettings) CreateRoomConfig

func WithSettingHidden added in v0.5.0

func WithSettingHidden(hidden bool) CreateRoomConfig

func WithStatus

func WithStatus(status model.RoomStatus) CreateRoomConfig

type CreateRoomMemberRelationConfig added in v0.5.0

type CreateRoomMemberRelationConfig func(r *model.RoomMember)

func WithRoomMemberAdminPermissions added in v0.5.0

func WithRoomMemberAdminPermissions(permissions model.RoomAdminPermission) CreateRoomMemberRelationConfig

func WithRoomMemberPermissions added in v0.5.0

func WithRoomMemberPermissions(permissions model.RoomMemberPermission) CreateRoomMemberRelationConfig

func WithRoomMemberRole added in v0.5.0

func WithRoomMemberRole(role model.RoomMemberRole) CreateRoomMemberRelationConfig

func WithRoomMemberStatus added in v0.5.0

func WithRoomMemberStatus(status model.RoomMemberStatus) CreateRoomMemberRelationConfig

type CreateUserConfig

type CreateUserConfig func(u *model.User)

func WithAppendProvider

func WithAppendProvider(p provider.OAuth2Provider, puid string) CreateUserConfig

func WithAppendProviders

func WithAppendProviders(providers []*model.UserProvider) CreateUserConfig

func WithEmail added in v0.4.5

func WithEmail(email string) CreateUserConfig

func WithID added in v0.5.0

func WithID(id string) CreateUserConfig

func WithRegisteredByEmail added in v0.4.5

func WithRegisteredByEmail(b bool) CreateUserConfig

func WithRegisteredByProvider

func WithRegisteredByProvider(b bool) CreateUserConfig

func WithRole

func WithRole(role model.Role) CreateUserConfig

func WithSetProvider

func WithSetProvider(p provider.OAuth2Provider, puid string) CreateUserConfig

func WithSetProviders

func WithSetProviders(providers []*model.UserProvider) CreateUserConfig

type ErrNotFound added in v0.3.1

type ErrNotFound string

func (ErrNotFound) Error added in v0.3.1

func (e ErrNotFound) Error() string

Jump to

Keyboard shortcuts

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