Documentation
¶
Overview ¶
Package repository implements the data access layer for the CMS plugin.
Package repository implements the data access layer for the CMS plugin.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ComponentSchemaRepository ¶
type ComponentSchemaRepository interface {
// CRUD operations
Create(ctx context.Context, component *schema.ComponentSchema) error
FindByID(ctx context.Context, id xid.ID) (*schema.ComponentSchema, error)
FindByName(ctx context.Context, appID, envID xid.ID, name string) (*schema.ComponentSchema, error)
List(ctx context.Context, appID, envID xid.ID, query *core.ListComponentSchemasQuery) ([]*schema.ComponentSchema, int, error)
Update(ctx context.Context, component *schema.ComponentSchema) error
Delete(ctx context.Context, id xid.ID) error
HardDelete(ctx context.Context, id xid.ID) error
// Stats operations
Count(ctx context.Context, appID, envID xid.ID) (int, error)
ExistsWithName(ctx context.Context, appID, envID xid.ID, name string) (bool, error)
// Usage queries
FindUsages(ctx context.Context, appID, envID xid.ID, componentSlug string) ([]*schema.ContentField, error)
CountUsages(ctx context.Context, appID, envID xid.ID, componentSlug string) (int, error)
}
ComponentSchemaRepository defines the interface for component schema storage operations
func NewComponentSchemaRepository ¶
func NewComponentSchemaRepository(db *bun.DB) ComponentSchemaRepository
NewComponentSchemaRepository creates a new component schema repository instance
type ContentEntryRepository ¶
type ContentEntryRepository interface {
// CRUD operations
Create(ctx context.Context, entry *schema.ContentEntry) error
FindByID(ctx context.Context, id xid.ID) (*schema.ContentEntry, error)
FindByIDWithType(ctx context.Context, id xid.ID) (*schema.ContentEntry, error)
List(ctx context.Context, contentTypeID xid.ID, query *EntryListQuery) ([]*schema.ContentEntry, int, error)
Update(ctx context.Context, entry *schema.ContentEntry) error
Delete(ctx context.Context, id xid.ID) error
HardDelete(ctx context.Context, id xid.ID) error
// Bulk operations
BulkUpdateStatus(ctx context.Context, ids []xid.ID, status string) error
BulkDelete(ctx context.Context, ids []xid.ID) error
// Query operations
FindByFieldValue(ctx context.Context, contentTypeID xid.ID, field string, value interface{}) ([]*schema.ContentEntry, error)
ExistsWithFieldValue(ctx context.Context, contentTypeID xid.ID, field string, value interface{}, excludeID *xid.ID) (bool, error)
// Scheduled entries
FindScheduledForPublish(ctx context.Context, before time.Time) ([]*schema.ContentEntry, error)
// Stats operations
Count(ctx context.Context, contentTypeID xid.ID) (int, error)
CountByStatus(ctx context.Context, contentTypeID xid.ID) (map[string]int, error)
CountByAppEnv(ctx context.Context, appID, envID xid.ID) (int, error)
CountByAppEnvAndStatus(ctx context.Context, appID, envID xid.ID) (map[string]int, error)
}
ContentEntryRepository defines the interface for content entry storage operations
func NewContentEntryRepository ¶
func NewContentEntryRepository(db *bun.DB) ContentEntryRepository
NewContentEntryRepository creates a new content entry repository instance
type ContentFieldRepository ¶
type ContentFieldRepository interface {
// CRUD operations
Create(ctx context.Context, field *schema.ContentField) error
FindByID(ctx context.Context, id xid.ID) (*schema.ContentField, error)
FindByName(ctx context.Context, contentTypeID xid.ID, name string) (*schema.ContentField, error)
ListByContentType(ctx context.Context, contentTypeID xid.ID) ([]*schema.ContentField, error)
Update(ctx context.Context, field *schema.ContentField) error
Delete(ctx context.Context, id xid.ID) error
DeleteAllForContentType(ctx context.Context, contentTypeID xid.ID) error
// Ordering operations
UpdateOrder(ctx context.Context, id xid.ID, order int) error
ReorderFields(ctx context.Context, contentTypeID xid.ID, orders []FieldOrder) error
GetMaxOrder(ctx context.Context, contentTypeID xid.ID) (int, error)
// Stats operations
Count(ctx context.Context, contentTypeID xid.ID) (int, error)
ExistsWithName(ctx context.Context, contentTypeID xid.ID, name string) (bool, error)
}
ContentFieldRepository defines the interface for content field storage operations
func NewContentFieldRepository ¶
func NewContentFieldRepository(db *bun.DB) ContentFieldRepository
NewContentFieldRepository creates a new content field repository instance
type ContentTypeRepository ¶
type ContentTypeRepository interface {
// CRUD operations
Create(ctx context.Context, contentType *schema.ContentType) error
FindByID(ctx context.Context, id xid.ID) (*schema.ContentType, error)
FindByName(ctx context.Context, appID, envID xid.ID, name string) (*schema.ContentType, error)
List(ctx context.Context, appID, envID xid.ID, query *core.ListContentTypesQuery) ([]*schema.ContentType, int, error)
Update(ctx context.Context, contentType *schema.ContentType) error
Delete(ctx context.Context, id xid.ID) error
HardDelete(ctx context.Context, id xid.ID) error
// Relation queries
FindWithFields(ctx context.Context, id xid.ID) (*schema.ContentType, error)
FindByNameWithFields(ctx context.Context, appID, envID xid.ID, name string) (*schema.ContentType, error)
// Stats operations
Count(ctx context.Context, appID, envID xid.ID) (int, error)
CountEntries(ctx context.Context, contentTypeID xid.ID) (int, error)
ExistsWithName(ctx context.Context, appID, envID xid.ID, name string) (bool, error)
}
ContentTypeRepository defines the interface for content type storage operations
func NewContentTypeRepository ¶
func NewContentTypeRepository(db *bun.DB) ContentTypeRepository
NewContentTypeRepository creates a new content type repository instance
type EntryListQuery ¶
type EntryListQuery struct {
Status string
Search string
Filters map[string]FilterCondition
SortBy string
SortOrder string
Page int
PageSize int
Select []string
IncludeType bool
}
EntryListQuery defines query parameters for listing entries
type FieldOrder ¶
FieldOrder represents a field ID and its order
type FilterCondition ¶
type FilterCondition struct {
Operator string
Value interface{}
}
FilterCondition represents a filter condition
type RelationRepository ¶
type RelationRepository interface {
// Content Relations (entry-to-entry)
CreateRelation(ctx context.Context, relation *schema.ContentRelation) error
DeleteRelation(ctx context.Context, id xid.ID) error
DeleteRelationByEntries(ctx context.Context, sourceID, targetID xid.ID, fieldSlug string) error
DeleteAllForEntry(ctx context.Context, entryID xid.ID) error
DeleteAllForField(ctx context.Context, entryID xid.ID, fieldSlug string) error
FindRelations(ctx context.Context, sourceID xid.ID, fieldSlug string) ([]*schema.ContentRelation, error)
FindReverseRelations(ctx context.Context, targetID xid.ID, fieldSlug string) ([]*schema.ContentRelation, error)
FindAllRelations(ctx context.Context, entryID xid.ID) ([]*schema.ContentRelation, error)
UpdateRelationOrder(ctx context.Context, id xid.ID, order int) error
BulkCreateRelations(ctx context.Context, relations []*schema.ContentRelation) error
BulkUpdateOrder(ctx context.Context, sourceID xid.ID, fieldSlug string, orderedTargetIDs []xid.ID) error
// Content Type Relations (type-to-type definitions)
CreateTypeRelation(ctx context.Context, relation *schema.ContentTypeRelation) error
UpdateTypeRelation(ctx context.Context, relation *schema.ContentTypeRelation) error
DeleteTypeRelation(ctx context.Context, id xid.ID) error
FindTypeRelationByID(ctx context.Context, id xid.ID) (*schema.ContentTypeRelation, error)
FindTypeRelationByField(ctx context.Context, contentTypeID xid.ID, fieldSlug string) (*schema.ContentTypeRelation, error)
FindTypeRelationsForType(ctx context.Context, contentTypeID xid.ID) ([]*schema.ContentTypeRelation, error)
FindInverseRelation(ctx context.Context, targetTypeID xid.ID, targetField string) (*schema.ContentTypeRelation, error)
}
RelationRepository defines the interface for content relation storage operations
func NewRelationRepository ¶
func NewRelationRepository(db *bun.DB) RelationRepository
NewRelationRepository creates a new relation repository
type RevisionRepository ¶
type RevisionRepository interface {
// CRUD operations
Create(ctx context.Context, revision *schema.ContentRevision) error
FindByID(ctx context.Context, id xid.ID) (*schema.ContentRevision, error)
FindByVersion(ctx context.Context, entryID xid.ID, version int) (*schema.ContentRevision, error)
List(ctx context.Context, entryID xid.ID, page, pageSize int) ([]*schema.ContentRevision, int, error)
Delete(ctx context.Context, id xid.ID) error
DeleteAllForEntry(ctx context.Context, entryID xid.ID) error
DeleteOldRevisions(ctx context.Context, entryID xid.ID, keepCount int) error
// Stats operations
Count(ctx context.Context, entryID xid.ID) (int, error)
GetLatestVersion(ctx context.Context, entryID xid.ID) (int, error)
}
RevisionRepository defines the interface for content revision storage operations
func NewRevisionRepository ¶
func NewRevisionRepository(db *bun.DB) RevisionRepository
NewRevisionRepository creates a new revision repository instance