Skip to content

Instantly share code, notes, and snippets.

@LIQRGV
Last active November 18, 2022 11:20
Show Gist options
  • Save LIQRGV/930f09a9a938f18cf74df8eec2727a52 to your computer and use it in GitHub Desktop.
Save LIQRGV/930f09a9a938f18cf74df8eec2727a52 to your computer and use it in GitHub Desktop.
const getPagedUserIDByDateRangeAndWhitelist = `-- name: GetPagedUserIDByDateRangeAndWhitelist :many
SELECT user_id
FROM main_trx
WHERE created_at between ? AND ?
AND trx_amount > 0
AND user_id IN (???) LIMIT ?
`
type GetPagedHPEOvoIdByDateRangeAndWhitelistToExpiryParams struct {
CreatedAtStart sql.NullTime
CreatedAtEnd sql.NullTime
UserID []string
Limit int32
}
func (q *Queries) GetPagedUserIDByDateRangeAndWhitelist(ctx context.Context, arg getPagedUserIDByDateRangeAndWhitelist) ([]sql.NullString, error) {
argsWithInKeyword := [][]interface{} {
flattenDeep(arg.UserID),
}
fullQueryWithPlaceholder, fullArg, err := compileInQuery(getPagedUserIDByDateRangeAndWhitelist, argsWithInKeyword, arg)
if err != nil {
return nil, err
}
rows, err := q.db.QueryContext(ctx, fullQueryWithPlaceholder, fullArg...)
if err != nil {
return nil, err
}
defer rows.Close()
var items []sql.NullString
for rows.Next() {
var user_id sql.NullString
if err := rows.Scan(&user_id); err != nil {
return nil, err
}
items = append(items, user_id)
}
if err := rows.Close(); err != nil {
return nil, err
}
if err := rows.Err(); err != nil {
return nil, err
}
return items, nil
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment