Last active
November 18, 2022 11:20
-
-
Save LIQRGV/930f09a9a938f18cf74df8eec2727a52 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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