gen with sqlc
This commit is contained in:
parent
286f65ee38
commit
24b7942061
@ -1586,7 +1586,7 @@ func (q *Queries) GetResultAnswers(ctx context.Context, id int64) ([]GetResultAn
|
||||
}
|
||||
|
||||
const getUsersWithPagination = `-- name: GetUsersWithPagination :many
|
||||
SELECT id, accountid, amoid, name, email, role, "Group", deleted, createdat, subdomain, amouserid, country FROM users ORDER BY ID OFFSET ($1 - 1) * $2 LIMIT $2
|
||||
SELECT id, accountid, amoid, name, email, role, "Group", deleted, createdat, subdomain, amouserid, country, COUNT(*) OVER() as total_count FROM users WHERE Deleted = false ORDER BY ID OFFSET ($1 - 1) * $2 LIMIT $2
|
||||
`
|
||||
|
||||
type GetUsersWithPaginationParams struct {
|
||||
@ -1594,15 +1594,31 @@ type GetUsersWithPaginationParams struct {
|
||||
Limit int32 `db:"limit" json:"limit"`
|
||||
}
|
||||
|
||||
func (q *Queries) GetUsersWithPagination(ctx context.Context, arg GetUsersWithPaginationParams) ([]User, error) {
|
||||
type GetUsersWithPaginationRow struct {
|
||||
ID int64 `db:"id" json:"id"`
|
||||
Accountid string `db:"accountid" json:"accountid"`
|
||||
Amoid int32 `db:"amoid" json:"amoid"`
|
||||
Name string `db:"name" json:"name"`
|
||||
Email string `db:"email" json:"email"`
|
||||
Role string `db:"role" json:"role"`
|
||||
Group pqtype.NullRawMessage `db:"Group" json:"Group"`
|
||||
Deleted sql.NullBool `db:"deleted" json:"deleted"`
|
||||
Createdat sql.NullTime `db:"createdat" json:"createdat"`
|
||||
Subdomain string `db:"subdomain" json:"subdomain"`
|
||||
Amouserid int32 `db:"amouserid" json:"amouserid"`
|
||||
Country string `db:"country" json:"country"`
|
||||
TotalCount int64 `db:"total_count" json:"total_count"`
|
||||
}
|
||||
|
||||
func (q *Queries) GetUsersWithPagination(ctx context.Context, arg GetUsersWithPaginationParams) ([]GetUsersWithPaginationRow, error) {
|
||||
rows, err := q.db.QueryContext(ctx, getUsersWithPagination, arg.Column1, arg.Limit)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
defer rows.Close()
|
||||
var items []User
|
||||
var items []GetUsersWithPaginationRow
|
||||
for rows.Next() {
|
||||
var i User
|
||||
var i GetUsersWithPaginationRow
|
||||
if err := rows.Scan(
|
||||
&i.ID,
|
||||
&i.Accountid,
|
||||
@ -1616,6 +1632,7 @@ func (q *Queries) GetUsersWithPagination(ctx context.Context, arg GetUsersWithPa
|
||||
&i.Subdomain,
|
||||
&i.Amouserid,
|
||||
&i.Country,
|
||||
&i.TotalCount,
|
||||
); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user