add user login sessions
This commit is contained in:
@@ -67,6 +67,21 @@ func (q *Queries) CreateCustomer(ctx context.Context, arg CreateCustomerParams)
|
||||
return err
|
||||
}
|
||||
|
||||
const createNewSession = `-- name: CreateNewSession :exec
|
||||
INSERT INTO user_sessions (id, user_id, created_at) VALUES (?, ?, ?)
|
||||
`
|
||||
|
||||
type CreateNewSessionParams struct {
|
||||
ID string
|
||||
UserID string
|
||||
CreatedAt string
|
||||
}
|
||||
|
||||
func (q *Queries) CreateNewSession(ctx context.Context, arg CreateNewSessionParams) error {
|
||||
_, err := q.db.ExecContext(ctx, createNewSession, arg.ID, arg.UserID, arg.CreatedAt)
|
||||
return err
|
||||
}
|
||||
|
||||
const createUser = `-- name: CreateUser :exec
|
||||
INSERT INTO user (
|
||||
id
|
||||
@@ -177,6 +192,17 @@ func (q *Queries) GetCustomer(ctx context.Context, id string) (GetCustomerRow, e
|
||||
return i, err
|
||||
}
|
||||
|
||||
const getSession = `-- name: GetSession :one
|
||||
SELECT id, user_id, created_at FROM user_sessions WHERE user_id = ?
|
||||
`
|
||||
|
||||
func (q *Queries) GetSession(ctx context.Context, userID string) (UserSession, error) {
|
||||
row := q.db.QueryRowContext(ctx, getSession, userID)
|
||||
var i UserSession
|
||||
err := row.Scan(&i.ID, &i.UserID, &i.CreatedAt)
|
||||
return i, err
|
||||
}
|
||||
|
||||
const getSvgCount = `-- name: GetSvgCount :one
|
||||
SELECT COUNT(*) as count FROM svg_icon
|
||||
`
|
||||
|
||||
Reference in New Issue
Block a user