23 lines
783 B
Plaintext
23 lines
783 B
Plaintext
---
|
|
globs: *.go
|
|
description: Database abstraction layer conventions
|
|
---
|
|
|
|
# Database Abstraction Standards
|
|
|
|
## High-Level Interface
|
|
The [db.go](mdc:db.go) file provides a high-level database interface. Always use these methods instead of raw GORM calls:
|
|
|
|
- `GetTokenForCharacter(characterName string) (*Token, error)`
|
|
- `SaveTokenForCharacter(token *Token) error`
|
|
- `AutoMigrate(dst ...interface{}) error`
|
|
|
|
## Never Use Raw GORM
|
|
- Don't call `s.db.DB().Where(...)` directly
|
|
- Don't call `s.db.DB().Save(...)` directly
|
|
- Always use the abstracted methods in the DB interface
|
|
|
|
## Database Operations
|
|
- All database operations should be logged with appropriate context
|
|
- Include character names in log messages for database operations
|
|
- Handle errors gracefully and log them with context |