Help us shape the future of Go! Take the 2026 Go Developer Survey

sqlstore

package
v0.0.4 Latest Latest
Warning

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

Go to latest
Published: Jan 19, 2026 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func New

New creates a new SQLStore

Types

type SQLStore

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

SQLStore implements the Store interface for SQL databases

func (*SQLStore) AssignRole

func (s *SQLStore) AssignRole(ctx context.Context, userID, roleID string) error

AssignRole assigns a role to a user

func (*SQLStore) BeginTx

func (s *SQLStore) BeginTx(ctx context.Context) (store.Store, error)

BeginTx starts a new transaction

func (*SQLStore) Close

func (s *SQLStore) Close() error

Close closes the database connection

func (*SQLStore) Commit

func (s *SQLStore) Commit() error

Commit commits the current transaction

func (*SQLStore) CreateEmailVerification

func (s *SQLStore) CreateEmailVerification(ctx context.Context, verification *models.EmailVerification) error

CreateEmailVerification creates a new email verification token

func (*SQLStore) CreateOAuthAccount

func (s *SQLStore) CreateOAuthAccount(ctx context.Context, account *models.OAuthAccount) error

CreateOAuthAccount creates a new OAuth account

func (*SQLStore) CreatePasswordReset

func (s *SQLStore) CreatePasswordReset(ctx context.Context, reset *models.PasswordReset) error

CreatePasswordReset creates a new password reset token

func (*SQLStore) CreatePermission

func (s *SQLStore) CreatePermission(ctx context.Context, permission *models.Permission) error

CreatePermission creates a new permission

func (*SQLStore) CreateRefreshToken

func (s *SQLStore) CreateRefreshToken(ctx context.Context, token *models.RefreshToken) error

CreateRefreshToken creates a new refresh token

func (*SQLStore) CreateRole

func (s *SQLStore) CreateRole(ctx context.Context, role *models.Role) error

CreateRole creates a new role

func (*SQLStore) CreateUser

func (s *SQLStore) CreateUser(ctx context.Context, user *models.User) error

CreateUser creates a new user

func (*SQLStore) DB

func (s *SQLStore) DB() *sql.DB

DB returns the underlying database connection

func (*SQLStore) DeleteExpiredEmailVerifications

func (s *SQLStore) DeleteExpiredEmailVerifications(ctx context.Context) error

DeleteExpiredEmailVerifications deletes expired email verifications

func (*SQLStore) DeleteExpiredPasswordResets

func (s *SQLStore) DeleteExpiredPasswordResets(ctx context.Context) error

DeleteExpiredPasswordResets deletes expired password resets

func (*SQLStore) DeleteExpiredRefreshTokens

func (s *SQLStore) DeleteExpiredRefreshTokens(ctx context.Context) error

DeleteExpiredRefreshTokens deletes all expired refresh tokens

func (*SQLStore) DeleteOAuthAccount

func (s *SQLStore) DeleteOAuthAccount(ctx context.Context, id string) error

DeleteOAuthAccount deletes an OAuth account

func (*SQLStore) DeletePermission

func (s *SQLStore) DeletePermission(ctx context.Context, id string) error

DeletePermission deletes a permission

func (*SQLStore) DeleteRole

func (s *SQLStore) DeleteRole(ctx context.Context, id string) error

DeleteRole deletes a role

func (*SQLStore) DeleteUser

func (s *SQLStore) DeleteUser(ctx context.Context, id string) error

DeleteUser deletes a user (soft delete by setting Active = false)

func (*SQLStore) GetEmailVerificationByToken

func (s *SQLStore) GetEmailVerificationByToken(ctx context.Context, token string) (*models.EmailVerification, error)

GetEmailVerificationByToken retrieves an email verification by token

func (*SQLStore) GetOAuthAccountByProviderID

func (s *SQLStore) GetOAuthAccountByProviderID(ctx context.Context, provider models.OAuthProvider, providerID string) (*models.OAuthAccount, error)

GetOAuthAccountByProviderID retrieves an OAuth account by provider and provider ID

func (*SQLStore) GetOAuthAccountsByUserID

func (s *SQLStore) GetOAuthAccountsByUserID(ctx context.Context, userID string) ([]*models.OAuthAccount, error)

GetOAuthAccountsByUserID retrieves all OAuth accounts for a user

func (*SQLStore) GetPasswordResetByToken

func (s *SQLStore) GetPasswordResetByToken(ctx context.Context, token string) (*models.PasswordReset, error)

GetPasswordResetByToken retrieves a password reset by token

func (*SQLStore) GetPermissionByID

func (s *SQLStore) GetPermissionByID(ctx context.Context, id string) (*models.Permission, error)

GetPermissionByID retrieves a permission by its ID

func (*SQLStore) GetPermissionByName

func (s *SQLStore) GetPermissionByName(ctx context.Context, name string) (*models.Permission, error)

GetPermissionByName retrieves a permission by its name

func (*SQLStore) GetPermissionByResourceAction added in v0.0.3

func (s *SQLStore) GetPermissionByResourceAction(ctx context.Context, resource, action string) (*models.Permission, error)

GetPermissionByResourceAction retrieves a permission by resource and action

func (*SQLStore) GetPermissionRoles

func (s *SQLStore) GetPermissionRoles(ctx context.Context, permissionID string) ([]*models.Role, error)

GetPermissionRoles retrieves all roles that have a specific permission

func (*SQLStore) GetRefreshTokenByToken

func (s *SQLStore) GetRefreshTokenByToken(ctx context.Context, token string) (*models.RefreshToken, error)

GetRefreshTokenByToken retrieves a refresh token by its token string

func (*SQLStore) GetRefreshTokensByUserID

func (s *SQLStore) GetRefreshTokensByUserID(ctx context.Context, userID string) ([]*models.RefreshToken, error)

GetRefreshTokensByUserID retrieves all refresh tokens for a user

func (*SQLStore) GetRoleByID

func (s *SQLStore) GetRoleByID(ctx context.Context, id string) (*models.Role, error)

GetRoleByID retrieves a role by its ID

func (*SQLStore) GetRoleByName

func (s *SQLStore) GetRoleByName(ctx context.Context, name string) (*models.Role, error)

GetRoleByName retrieves a role by its name

func (*SQLStore) GetRolePermissions

func (s *SQLStore) GetRolePermissions(ctx context.Context, roleID string) ([]*models.Permission, error)

GetRolePermissions retrieves all permissions for a role

func (*SQLStore) GetRoleUsers

func (s *SQLStore) GetRoleUsers(ctx context.Context, roleID string) ([]*models.User, error)

GetRoleUsers retrieves all users with a specific role

func (*SQLStore) GetUserByEmail

func (s *SQLStore) GetUserByEmail(ctx context.Context, email string) (*models.User, error)

GetUserByEmail retrieves a user by their email address

func (*SQLStore) GetUserByID

func (s *SQLStore) GetUserByID(ctx context.Context, id string) (*models.User, error)

GetUserByID retrieves a user by their ID

func (*SQLStore) GetUserDirectPermissions added in v0.0.4

func (s *SQLStore) GetUserDirectPermissions(ctx context.Context, userID string) ([]*models.Permission, error)

GetUserDirectPermissions retrieves all permissions granted directly to a user

func (*SQLStore) GetUserRoles

func (s *SQLStore) GetUserRoles(ctx context.Context, userID string) ([]*models.Role, error)

GetUserRoles retrieves all roles for a user

func (*SQLStore) GrantPermission

func (s *SQLStore) GrantPermission(ctx context.Context, roleID, permissionID string) error

GrantPermission grants a permission to a role

func (*SQLStore) GrantUserPermission added in v0.0.4

func (s *SQLStore) GrantUserPermission(ctx context.Context, userID, permissionID string) error

GrantUserPermission grants a permission directly to a user

func (*SQLStore) HasPermissionByName added in v0.0.3

func (s *SQLStore) HasPermissionByName(ctx context.Context, userID, permissionName string) (bool, error)

HasPermissionByName checks if a user has a specific permission by permission name

func (*SQLStore) HasRole

func (s *SQLStore) HasRole(ctx context.Context, userID, roleName string) (bool, error)

HasRole checks if a user has a specific role

func (*SQLStore) HasRolePermission added in v0.0.3

func (s *SQLStore) HasRolePermission(ctx context.Context, roleID, permissionID string) (bool, error)

HasRolePermission checks if a role has a specific permission

func (*SQLStore) ListPermissions

func (s *SQLStore) ListPermissions(ctx context.Context) ([]*models.Permission, error)

ListPermissions retrieves all permissions

func (*SQLStore) ListRoles

func (s *SQLStore) ListRoles(ctx context.Context) ([]*models.Role, error)

ListRoles retrieves all roles

func (*SQLStore) ListUsers

func (s *SQLStore) ListUsers(ctx context.Context, limit, offset int) ([]*models.User, error)

ListUsers retrieves all users with pagination

func (*SQLStore) MarkEmailVerificationUsed

func (s *SQLStore) MarkEmailVerificationUsed(ctx context.Context, id string) error

MarkEmailVerificationUsed marks an email verification as used

func (*SQLStore) MarkPasswordResetUsed

func (s *SQLStore) MarkPasswordResetUsed(ctx context.Context, id string) error

MarkPasswordResetUsed marks a password reset as used

func (*SQLStore) RemoveRole

func (s *SQLStore) RemoveRole(ctx context.Context, userID, roleID string) error

RemoveRole removes a role from a user

func (*SQLStore) RevokeAllRefreshTokensForUser

func (s *SQLStore) RevokeAllRefreshTokensForUser(ctx context.Context, userID string) error

RevokeAllRefreshTokensForUser revokes all refresh tokens for a user

func (*SQLStore) RevokePermission

func (s *SQLStore) RevokePermission(ctx context.Context, roleID, permissionID string) error

RevokePermission revokes a permission from a role

func (*SQLStore) RevokeRefreshToken

func (s *SQLStore) RevokeRefreshToken(ctx context.Context, token string) error

RevokeRefreshToken revokes a refresh token

func (*SQLStore) RevokeUserPermission added in v0.0.4

func (s *SQLStore) RevokeUserPermission(ctx context.Context, userID, permissionID string) error

RevokeUserPermission revokes a permission directly from a user

func (*SQLStore) Rollback

func (s *SQLStore) Rollback() error

Rollback rolls back the current transaction

func (*SQLStore) UpdateOAuthAccount

func (s *SQLStore) UpdateOAuthAccount(ctx context.Context, account *models.OAuthAccount) error

UpdateOAuthAccount updates an existing OAuth account

func (*SQLStore) UpdatePermission

func (s *SQLStore) UpdatePermission(ctx context.Context, permission *models.Permission) error

UpdatePermission updates an existing permission

func (*SQLStore) UpdateRole

func (s *SQLStore) UpdateRole(ctx context.Context, role *models.Role) error

UpdateRole updates an existing role

func (*SQLStore) UpdateUser

func (s *SQLStore) UpdateUser(ctx context.Context, user *models.User) error

UpdateUser updates an existing user

Jump to

Keyboard shortcuts

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