UpdateLastUsed updates the last_used_at timestamp for an API key to the current time. This function is typically called during authentication to track API key usage patterns. Note: This does NOT invalidate the cache to avoid performance overhead on every request. The cached version will still work f
(ctx context.Context, id string)
| 270 | // Returns: |
| 271 | // - error: An error if the database update operation fails. |
| 272 | func (s *Datasource) UpdateLastUsed(ctx context.Context, id string) error { |
| 273 | query := ` |
| 274 | UPDATE ledgerforge.api_keys |
| 275 | SET last_used_at = $1 |
| 276 | WHERE api_key_id = $2 |
| 277 | ` |
| 278 | |
| 279 | _, err := s.Conn.ExecContext(ctx, query, time.Now(), id) |
| 280 | return err |
| 281 | } |
| 282 | |
| 283 | // ListAPIKeys retrieves all API keys belonging to a specific owner from the database. |
| 284 | // The results are ordered by creation date in descending order (newest first). |
no outgoing calls