mirror of
https://github.com/SamyRai/tercul-backend.git
synced 2025-12-27 00:31:35 +00:00
- Core Go application with GraphQL API using gqlgen - Comprehensive data models for literary works, authors, translations - Repository pattern with caching layer - Authentication and authorization system - Linguistics analysis capabilities with multiple adapters - Vector search integration with Weaviate - Docker containerization support - Python data migration and analysis scripts - Clean architecture with proper separation of concerns - Production-ready configuration and middleware - Proper .gitignore excluding vendor/, database files, and build artifacts
36 lines
968 B
Go
36 lines
968 B
Go
package repositories
|
|
|
|
import (
|
|
"context"
|
|
"gorm.io/gorm"
|
|
"tercul/models"
|
|
)
|
|
|
|
// EdgeRepository defines CRUD operations for the polymorphic edge table.
|
|
type EdgeRepository interface {
|
|
BaseRepository[models.Edge]
|
|
ListBySource(ctx context.Context, sourceTable string, sourceID uint) ([]models.Edge, error)
|
|
}
|
|
|
|
type edgeRepository struct {
|
|
BaseRepository[models.Edge]
|
|
db *gorm.DB
|
|
}
|
|
|
|
// NewEdgeRepository creates a new EdgeRepository.
|
|
func NewEdgeRepository(db *gorm.DB) EdgeRepository {
|
|
return &edgeRepository{
|
|
BaseRepository: NewBaseRepositoryImpl[models.Edge](db),
|
|
db: db,
|
|
}
|
|
}
|
|
|
|
// ListBySource finds edges by source table and ID
|
|
func (r *edgeRepository) ListBySource(ctx context.Context, sourceTable string, sourceID uint) ([]models.Edge, error) {
|
|
var edges []models.Edge
|
|
if err := r.db.WithContext(ctx).Where("source_table = ? AND source_id = ?", sourceTable, sourceID).Find(&edges).Error; err != nil {
|
|
return nil, err
|
|
}
|
|
return edges, nil
|
|
}
|