Documentation
¶
Overview ¶
Package persistence implements the restaurant repository using GORM for PostgreSQL It implements the restaurant.Repository interface defined in the restaurant domain, providing methods for creating, retrieving, updating, and deleting restaurant records in a PostgreSQL database using GORM as the ORM.
Package persistence implements the user repository using PostgreSQL as the database. It implements the UserRepository interface defined in the user domain, providing methods for creating, retrieving, updating, and deleting user records in a PostgreSQL database using GORM as the ORM.
Index ¶
- func NewRestaurantRepository(db *gorm.DB, log *zerolog.Logger) *restaurantRepository
- func NewUserRepository(db *gorm.DB, log *zerolog.Logger) user.Repository
- type UserSessionRepository
- func (r *UserSessionRepository) Create(ctx context.Context, entity *session.UserSessions) error
- func (r *UserSessionRepository) DeleteByToken(ctx context.Context, token string) error
- func (r *UserSessionRepository) DeleteByUserID(ctx context.Context, userID uuid.UUID) error
- func (r *UserSessionRepository) GetByToken(ctx context.Context, token string) (*session.UserSessions, error)
- func (r *UserSessionRepository) GetByUserID(ctx context.Context, userID uuid.UUID) ([]session.UserSessions, error)
- func (r *UserSessionRepository) Update(ctx context.Context, entity *session.UserSessions) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func NewRestaurantRepository ¶
NewRestaurantRepository creates a new instance of the GORM repository
func NewUserRepository ¶
Types ¶
type UserSessionRepository ¶
type UserSessionRepository struct {
// contains filtered or unexported fields
}
func NewUserSessionRepository ¶
func NewUserSessionRepository( db *gorm.DB, log *zerolog.Logger) *UserSessionRepository
func (*UserSessionRepository) Create ¶
func (r *UserSessionRepository) Create( ctx context.Context, entity *session.UserSessions, ) error
Create creates a new user session in the database
func (*UserSessionRepository) DeleteByToken ¶
func (r *UserSessionRepository) DeleteByToken( ctx context.Context, token string, ) error
DeleteByToken deletes a user session by its token Delete from database first, then redis
func (*UserSessionRepository) DeleteByUserID ¶
DeleteByUserID deletes all user sessions for a given user ID Delete from database first, then redis
func (*UserSessionRepository) GetByToken ¶
func (r *UserSessionRepository) GetByToken( ctx context.Context, token string, ) (*session.UserSessions, error)
GetByToken retrieves a user session by its token from database
func (*UserSessionRepository) GetByUserID ¶
func (r *UserSessionRepository) GetByUserID( ctx context.Context, userID uuid.UUID, ) ([]session.UserSessions, error)
GetByUserID retrieves all user sessions for a given user ID
func (*UserSessionRepository) Update ¶
func (r *UserSessionRepository) Update( ctx context.Context, entity *session.UserSessions, ) error
Update user session in database