Documentation ¶
Index ¶
- func CryptPassword(raw string) (string, error)
- func IsPasswordValid(hash string, raw string) bool
- func SessionJoinSQL(prefix string) string
- func UserExists(id string) (bool, error)
- func UserJoinSQL(prefix string) string
- type Session
- func (s *Session) Create() error
- func (s *Session) CreateQ(q db.Queryable) error
- func (s *Session) Delete() error
- func (s *Session) DeleteQ(q db.Queryable) error
- func (s *Session) Exists() (bool, error)
- func (s *Session) FullyDelete() error
- func (s *Session) FullyDeleteQ(q db.Queryable) error
- func (s *Session) IsZero() bool
- func (s *Session) Save() error
- func (s *Session) SaveQ(q db.Queryable) error
- type User
- func (u *User) Create() error
- func (u *User) CreateQ(q db.Queryable) error
- func (u *User) Delete() error
- func (u *User) DeleteQ(q db.Queryable) error
- func (u *User) FullyDelete() error
- func (u *User) FullyDeleteQ(q db.Queryable) error
- func (u *User) IsZero() bool
- func (u *User) Save() error
- func (u *User) SaveQ(q db.Queryable) error
- func (u *User) Update() error
- func (u *User) UpdateQ(q db.Queryable) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CryptPassword ¶
CryptPassword returns a password encrypted with bcrypt
func IsPasswordValid ¶
IsPasswordValid Compare a bcrypt hash with a raw string and check if they match
func SessionJoinSQL ¶
SessionJoinSQL returns a string ready to be embed in a JOIN query
func UserExists ¶
UserExists checks if a user exists for a specific ID
func UserJoinSQL ¶
UserJoinSQL returns a string ready to be embed in a JOIN query
Types ¶
type Session ¶
type Session struct { ID string `db:"id"` CreatedAt *db.Time `db:"created_at"` UpdatedAt *db.Time `db:"updated_at"` DeletedAt *db.Time `db:"deleted_at"` UserID string `db:"user_id"` }
Session is a structure representing a session that can be saved in the database
func (*Session) FullyDelete ¶
FullyDelete removes a session from the database
func (*Session) FullyDeleteQ ¶
FullyDeleteQ removes a session from the database using a transaction
type User ¶
type User struct { ID string `db:"id"` CreatedAt *db.Time `db:"created_at"` UpdatedAt *db.Time `db:"updated_at"` DeletedAt *db.Time `db:"deleted_at"` Name string `db:"name"` Email string `db:"email"` Password string `db:"password"` IsAdmin bool `db:"is_admin"` }
User is a structure representing a user that can be saved in the database
func (*User) FullyDelete ¶
FullyDelete removes a user from the database
func (*User) FullyDeleteQ ¶
FullyDeleteQ removes a user from the database using a transaction
func (*User) SaveQ ¶
SaveQ creates or updates the article depending on the value of the id using a transaction