Select models by array of ids #375
Unanswered
satanworker
asked this question in
Q&A
Replies: 1 comment 1 reply
-
This seems to be working fine, but not sure if that's a proper way func (u *BalanceRepository) GetBalancesByIds(tx *db.Tx, ids []int32) ([]BalanceModel, error) {
intIds := make([]Expression, len(ids))
// TODO: not sure if that works
for i, id := range ids {
intIds[i] = Int32(id)
}
stmt := Balance.
SELECT(Balance.AllColumns).
WHERE(
Balance.ID.IN(intIds...),
)
var balances []BalanceModel
err := stmt.Query(tx, &balances)
return balances, err
} |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
I'm trying to select rows with a list of ids, but can't find proper type to do it and nowhere find any examples
Beta Was this translation helpful? Give feedback.
All reactions