Documentation ¶
Index ¶
- Constants
- Variables
- type CachedRepo
- func (r *CachedRepo) FindRelevant(user *model.User, hobbies []model.Hobby, exceptUser []cachemodels.CachedUser, ...) ([]cachemodels.CachedUser, error)
- func (r *CachedRepo) Get(limit int) ([]cachemodels.CachedUser, error)
- func (r *CachedRepo) GetByUsername(username string) (*cachemodels.CachedUser, error)
- type DatabaseRepo
- type ICachedRepo
- type IConversationRepo
- type IHobbyRepo
- type ILikeAndDislikeRepo
- type IMessageRepo
- type IParticipantRepo
- type IUserHobbyRepo
- type IUserImgRepo
- type IUserRepo
- type MySQLConversationRepo
- type MySQLHobbyRepo
- type MySQLLikeAndDislikeRepo
- type MySQLMessageRepo
- type MySQLParticipantRepo
- type MySQLUserHobbyRepo
- type MySQLUserImgRepo
- type MySQLUserRepo
- func (userRepo *MySQLUserRepo) Count() int
- func (userRepo *MySQLUserRepo) Create(user *model.User) error
- func (userRepo *MySQLUserRepo) FindSecretKey(uname string) ([]byte, error)
- func (userRepo *MySQLUserRepo) GetAll() ([]model.User, error)
- func (userRepo *MySQLUserRepo) GetByEmail(email string) (*model.User, error)
- func (userRepo *MySQLUserRepo) GetByID(id int) (*model.User, error)
- func (userRepo *MySQLUserRepo) GetByUsername(username string) (*model.User, error)
- func (userRepo *MySQLUserRepo) GetMatches(userID int) ([]model.User, error)
- func (userRepo *MySQLUserRepo) RenewSecretKey(userID int) error
- func (userRepo *MySQLUserRepo) Update(u *model.User) error
- func (userRepo *MySQLUserRepo) UpdateAvatar(username, pathImg string) error
- func (userRepo *MySQLUserRepo) UpdateLastSeen(username string) error
- func (userRepo *MySQLUserRepo) UpdatePassword(userID int, password string) error
Constants ¶
const (
StatusMatched = 21
)
Like and dislike status
Variables ¶
var ErrInsufficentMessages = errors.New("insufficent messages to load")
ErrInsufficentMessages indicate there are not enough messages to load base on provided length
var (
ErrNoRows = errors.New("Error no rows")
)
Functions ¶
This section is empty.
Types ¶
type CachedRepo ¶
type CachedRepo struct { Conn *gorm.DB LikeAndDislikeRepo ILikeAndDislikeRepo }
func (*CachedRepo) FindRelevant ¶
func (r *CachedRepo) FindRelevant(user *model.User, hobbies []model.Hobby, exceptUser []cachemodels.CachedUser, nUser int) ([]cachemodels.CachedUser, error)
func (*CachedRepo) Get ¶
func (r *CachedRepo) Get(limit int) ([]cachemodels.CachedUser, error)
func (*CachedRepo) GetByUsername ¶
func (r *CachedRepo) GetByUsername(username string) (*cachemodels.CachedUser, error)
type DatabaseRepo ¶
type DatabaseRepo struct { UserRepo IUserRepo HobbyRepo IHobbyRepo UserHobbyRepo IUserHobbyRepo UserImgRepo IUserImgRepo LikeAndDislikeRepo ILikeAndDislikeRepo CachedRepo ICachedRepo ConversationRepo IConversationRepo ParticipantRepo IParticipantRepo MessageRepo IMessageRepo }
DatabaseRepo is a struct that contains ALL repositories that use databse connection. This is use to group repositories' creation to one function NewDatabaseRepo
func NewDatabaseRepo ¶
func NewDatabaseRepo(conn *gorm.DB) *DatabaseRepo
NewDatabaseRepo is a function to create all database (MySQL) repositories from one database connection
type ICachedRepo ¶
type ICachedRepo interface { Get(limit int) ([]cachemodels.CachedUser, error) GetByUsername(username string) (*cachemodels.CachedUser, error) FindRelevant(user *model.User, hobbies []model.Hobby, exceptUser []cachemodels.CachedUser, nUser int) ([]cachemodels.CachedUser, error) }
func NewCahedRepo ¶
func NewCahedRepo(conn *gorm.DB) ICachedRepo
type IConversationRepo ¶
type IConversationRepo interface { Create(c *model.Conversation) (*model.Conversation, error) GetByUserIds(userId1, userId2 int) (*model.Conversation, error) }
type IHobbyRepo ¶
type IHobbyRepo interface { GetAll() ([]model.Hobby, error) GetByID(id int) (*model.Hobby, error) GetByUser(user *model.User) (hobbies []model.Hobby, err error) }
IHobbyRepo is an interface for interest repo to follow
func NewMySQLHobbyRepo ¶
func NewMySQLHobbyRepo(conn *gorm.DB) IHobbyRepo
type ILikeAndDislikeRepo ¶
type ILikeAndDislikeRepo interface { Create(likeDislike *model.LikeAndDislike) error Update(likeDislike *model.LikeAndDislike) error GetByUserIDs(userID1, userID2 int) (*model.LikeAndDislike, error) }
func NewMySQLLikeAndDislikeRepo ¶
func NewMySQLLikeAndDislikeRepo(conn *gorm.DB) ILikeAndDislikeRepo
NewMySQLLikeAndDislikeRepo return an instance of type MySQLUserRepo
type IMessageRepo ¶
type IParticipantRepo ¶
type IParticipantRepo interface { Create(c *model.Participant) error JoinConversation(p *model.User, c *model.Conversation) (*model.Participant, error) }
type IUserHobbyRepo ¶
type IUserHobbyRepo interface { Create(*model.UserHobby) error DeleteHobby(*model.UserHobby) error }
func NewMySQLUserHobbyRepo ¶
func NewMySQLUserHobbyRepo(conn *gorm.DB) IUserHobbyRepo
NewMySQLUserRepo return an instance of type MySQLUserRepo
type IUserImgRepo ¶
type IUserImgRepo interface { Create(*model.UserImg) error AllByUser(*model.User) ([]model.UserImg, error) GetById(id int) (*model.UserImg, error) Delete(usrimg *model.UserImg) error }
func NewMySQLUserImgRepo ¶
func NewMySQLUserImgRepo(conn *gorm.DB) IUserImgRepo
type IUserRepo ¶
type IUserRepo interface { UpdatePassword(userID int, password string) error GetByID(id int) (*model.User, error) Count() int GetAll() ([]model.User, error) GetByEmail(email string) (*model.User, error) GetByUsername(username string) (*model.User, error) Create(user *model.User) error RenewSecretKey(userID int) error FindSecretKey(uname string) ([]byte, error) UpdateAvatar(username, pathImg string) error UpdateLastSeen(username string) error GetMatches(userID int) ([]model.User, error) Update(*model.User) error }
IUserRepo is an interface for user repositories to follow. This repository's purpose is to provide functions for CRUD database on `users` table.
func NewMySQLUserRepo ¶
NewMySQLUserRepo return an instance of type MySQLUserRepo
type MySQLConversationRepo ¶
func NewMySQLConversationRepo ¶
func NewMySQLConversationRepo(conn *gorm.DB) *MySQLConversationRepo
func (*MySQLConversationRepo) Create ¶
func (cr *MySQLConversationRepo) Create(c *model.Conversation) (*model.Conversation, error)
func (*MySQLConversationRepo) GetByUserIds ¶
func (cr *MySQLConversationRepo) GetByUserIds(user_id1, user_id2 int) (*model.Conversation, error)
type MySQLHobbyRepo ¶
type MySQLLikeAndDislikeRepo ¶
MySQLLikeAndDislikeRepo contains gorm.DB connection
func (*MySQLLikeAndDislikeRepo) Create ¶
func (l *MySQLLikeAndDislikeRepo) Create(likeDislike *model.LikeAndDislike) error
func (*MySQLLikeAndDislikeRepo) GetByUserIDs ¶
func (l *MySQLLikeAndDislikeRepo) GetByUserIDs(userID1, userID2 int) (*model.LikeAndDislike, error)
func (*MySQLLikeAndDislikeRepo) Update ¶
func (l *MySQLLikeAndDislikeRepo) Update(likeDislike *model.LikeAndDislike) error
type MySQLMessageRepo ¶
func NewMySQLMessageRepo ¶
func NewMySQLMessageRepo(conn *gorm.DB) *MySQLMessageRepo
func (*MySQLMessageRepo) GetByConversation ¶
func (mr *MySQLMessageRepo) GetByConversation(c *model.Conversation, offset, length int) ([]model.Message, error)
type MySQLParticipantRepo ¶
func NewMySQLParticipantRepo ¶
func NewMySQLParticipantRepo(conn *gorm.DB) *MySQLParticipantRepo
func (*MySQLParticipantRepo) Create ¶
func (pr *MySQLParticipantRepo) Create(c *model.Participant) error
func (*MySQLParticipantRepo) JoinConversation ¶
func (pr *MySQLParticipantRepo) JoinConversation(p *model.User, c *model.Conversation) (*model.Participant, error)
type MySQLUserHobbyRepo ¶
MySQLUserRepo contains gorm.DB connection
func (MySQLUserHobbyRepo) DeleteHobby ¶
func (uhr MySQLUserHobbyRepo) DeleteHobby(uh *model.UserHobby) error
type MySQLUserImgRepo ¶
func (*MySQLUserImgRepo) Create ¶
func (userImgRepo *MySQLUserImgRepo) Create(userImg *model.UserImg) error
type MySQLUserRepo ¶
MySQLUserRepo contains gorm.DB connection
func (*MySQLUserRepo) Count ¶
func (userRepo *MySQLUserRepo) Count() int
Count return number of User in database
func (*MySQLUserRepo) Create ¶
func (userRepo *MySQLUserRepo) Create(user *model.User) error
Create save user to database
func (*MySQLUserRepo) FindSecretKey ¶
func (userRepo *MySQLUserRepo) FindSecretKey(uname string) ([]byte, error)
FindSecretKey return secretkey of a user
func (*MySQLUserRepo) GetAll ¶
func (userRepo *MySQLUserRepo) GetAll() ([]model.User, error)
GetAll return all of user exists in datatabse
func (*MySQLUserRepo) GetByEmail ¶
func (userRepo *MySQLUserRepo) GetByEmail(email string) (*model.User, error)
GetByEmail return user have email is parameter email
func (*MySQLUserRepo) GetByID ¶
func (userRepo *MySQLUserRepo) GetByID(id int) (*model.User, error)
GetByID return a user based on his ID
func (*MySQLUserRepo) GetByUsername ¶
func (userRepo *MySQLUserRepo) GetByUsername(username string) (*model.User, error)
GetByUsername ...
func (*MySQLUserRepo) GetMatches ¶
func (userRepo *MySQLUserRepo) GetMatches(userID int) ([]model.User, error)
func (*MySQLUserRepo) RenewSecretKey ¶
func (userRepo *MySQLUserRepo) RenewSecretKey(userID int) error
RenewSecretKey create a new secretkey for user
func (*MySQLUserRepo) UpdateAvatar ¶
func (userRepo *MySQLUserRepo) UpdateAvatar(username, pathImg string) error
func (*MySQLUserRepo) UpdateLastSeen ¶
func (userRepo *MySQLUserRepo) UpdateLastSeen(username string) error
UpdateLastSeen update last seen of user
func (*MySQLUserRepo) UpdatePassword ¶
func (userRepo *MySQLUserRepo) UpdatePassword(userID int, password string) error
UpdatePassword update password