Returns all keys for the requested providers, ordered by provider then created_at ASC so callers can select the oldest non-empty key per provider without issuing N queries.
(ctx context.Context, providerIds []uuid.UUID)
| 292 | // Returns all keys for the requested providers, ordered by provider then created_at ASC |
| 293 | // so callers can select the oldest non-empty key per provider without issuing N queries. |
| 294 | func (q *sqlQuerier) GetAIProviderKeysByProviderIDs(ctx context.Context, providerIds []uuid.UUID) ([]AIProviderKey, error) { |
| 295 | rows, err := q.db.QueryContext(ctx, getAIProviderKeysByProviderIDs, pq.Array(providerIds)) |
| 296 | if err != nil { |
| 297 | return nil, err |
| 298 | } |
| 299 | defer rows.Close() |
| 300 | var items []AIProviderKey |
| 301 | for rows.Next() { |
| 302 | var i AIProviderKey |
| 303 | if err := rows.Scan( |
| 304 | &i.ID, |
| 305 | &i.ProviderID, |
| 306 | &i.APIKey, |
| 307 | &i.ApiKeyKeyID, |
| 308 | &i.CreatedAt, |
| 309 | &i.UpdatedAt, |
| 310 | ); err != nil { |
| 311 | return nil, err |
| 312 | } |
| 313 | items = append(items, i) |
| 314 | } |
| 315 | if err := rows.Close(); err != nil { |
| 316 | return nil, err |
| 317 | } |
| 318 | if err := rows.Err(); err != nil { |
| 319 | return nil, err |
| 320 | } |
| 321 | return items, nil |
| 322 | } |
| 323 | |
| 324 | const insertAIProviderKey = `-- name: InsertAIProviderKey :one |
| 325 | INSERT INTO ai_provider_keys ( |
nothing calls this directly
no test coverage detected