database

package
v0.2.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 7, 2026 License: MIT Imports: 105 Imported by: 0

Documentation

Index

Constants

View Source
const SettingsRowID = settingsRowID

SettingsRowID - the id of a settings table's single row (a module's settings).

Variables

This section is empty.

Functions

func ClientFor

func ClientFor(db *sql.DB) *generated.Client

ClientFor - an ent client on db in the configured dialect (a module's repository built on the shared *sql.DB).

func CommentOnPublicNode

func CommentOnPublicNode() predicate.Comment

CommentOnPublicNode - the comments on public content only (published, not on moderation): what the public comment lists show.

func ContentListPredicate

func ContentListPredicate(ctx context.Context) predicate.Node

ContentListPredicate - the content lists' narrowing for ctx (nil - none).

func Dialect

func Dialect() string

Dialect - the database the repositories' ent clients speak (SetDialect): a module's own ent client (its own schema) opens its driver with it.

func GetClient

func GetClient(ctx context.Context, defaultClient *generated.Client) *generated.Client

GetClient returns the transactional client from ctx, or the given client if there is no transaction.

func InTxDriver

func InTxDriver(d string, eq entsql.ExecQuerier) dialect.Driver

InTxDriver - a transaction running queries through eq (a transaction's client) as an ent driver: a transaction ent begins on it (an update with edges does) is that one, committed or rolled back by its owner.

func NewDynamicContentRepositoryFactory

func NewDynamicContentRepositoryFactory(
	client *generated.Client,
	contentTypeRepo entity.ContentTypeRepository,
	taxonomyRepo entity.TaxonomyRepository,
) func(entity.ContentTypeDef, entity.FieldInstanceDefs) entity.DynamicContentRepository

NewDynamicContentRepositoryFactory returns a factory the interfaces layer can hold without importing ent: it captures the ent client and content type repository at wiring time and returns an entity.DynamicContentRepository per resolved content type.

func NodeIDsWithField

func NodeIDsWithField(ctx context.Context, client *generated.Client, fs entity.FieldStorageDef) ([]int, bool, error)

NodeIDsWithField - the nodes having any value of the field, a node with several values repeated; false for a field type without a value table.

func OnContentChange

func OnContentChange(client *generated.Client, changed func())

OnContentChange calls changed after each change of the content written through client - a node's or a comment's, created, updated or deleted: once its transaction commits (never on a rollback), at once outside one. It runs for each change, a bulk update's once: changed should be cheap (a debounced refresh). Writes through clients of their own (clientFor: the deletions' raw paths) aren't seen: they signal their own.

func OrderByCounter

func OrderByCounter(column string, desc bool) node.OrderOption

OrderByCounter orders nodes by a node_counter column (totalcount, daycount), 0 for a node without a counter row. Not ent's node.ByNodeCounterField: for an edge keyed on node_counter it joins a "GROUP BY nid" subquery selecting the column, which PostgreSQL rejects (the column is neither grouped nor aggregated).

func OrderByViewDays

func OrderByViewDays(since int, desc bool) node.OrderOption

OrderByViewDays orders nodes by their views from the day since on (node_view_days), 0 for a node not viewed then. since is written as a number, not an argument: ent drops an ORDER BY expression's arguments (MySQL: "expected 2 arguments, got 1"); it is an int, never text.

func OrderRandom

func OrderRandom(s *entsql.Selector)

OrderRandom - ent order option shuffling the rows (a module's query).

func Rebind

func Rebind(query string) string

Rebind - a module's hand-written query (? placeholders) in the placeholders of the repositories' database.

func RebuildSearchIndex

func RebuildSearchIndex(ctx context.Context, client *generated.Client) (int, error)

RebuildSearchIndex writes the words of every node again (app search reindex, a new site's content): a batch of nodes at a time, each batch's old words replaced, so the search keeps finding meanwhile. It returns how many nodes it indexed.

func SealSecrets

func SealSecrets(ctx context.Context, db *sql.DB) (int, map[string]int, error)

SealSecrets seals again what isn't sealed with the site's first key: the plain secrets (saved before the site had a key) and the ones sealed with an older key (SECRETS_KEY "new,old"). It returns how many it sealed and, per column (secretColumn.label), how many none of the keys opens.

func SecretsKeyWeak

func SecretsKeyWeak() bool

SecretsKeyWeak - whether the site's key is guessable (secretbox.Box.Weak).

func SecretsSealed

func SecretsSealed() bool

SecretsSealed - whether the site has a key to seal the secrets with.

func SetContentListFilter

func SetContentListFilter(fn func(ctx context.Context) func(*entsql.Selector))

SetContentListFilter sets what narrows the content lists' nodes (every content View's, the search's) for ctx's request: fn returns the condition to add to the nodes' query (its Where on the nodes' selector), nil - none. nil fn - no narrowing.

func SetDialect

func SetDialect(d string)

SetDialect sets the database those repositories' ent clients speak (dialect.MySQL, dialect.Postgres).

func SetSecrets

func SetSecrets(b *secretbox.Box)

SetSecrets sets the key the secrets are sealed with (at startup).

func TodayStartSite

func TodayStartSite() time.Time

TodayStartSite returns midnight in the site's time zone (pkg/sitetime): where "viewed today" starts (node_counter.daycount, ViewSortBuiltinViewsToday).

func TxDriver

func TxDriver(ctx context.Context) (dialect.Driver, bool)

TxDriver - the context's transaction (a unit of work's) as an ent driver, for a module's own client writing in it (modulekit.Driver); false outside one.

func UnreadableSecrets

func UnreadableSecrets(ctx context.Context, db *sql.DB) (map[string]int, error)

UnreadableSecrets - per column (secretColumn.label), how many stored secrets none of the site's keys opens: sealed with a key the site no longer has.

func ViewDaysSince

func ViewDaysSince(days int) int

ViewDaysSince - the first day (entity.ViewDay) of the last days of views, today included.

func WithContentListFilter

func WithContentListFilter(ctx context.Context, predicates []predicate.Node) []predicate.Node

WithContentListFilter - predicates with the content lists' narrowing for ctx.

Types

type AccountSettingsRepository

type AccountSettingsRepository struct {
	// contains filtered or unexported fields
}

AccountSettingsRepository implements entity.AccountSettingsRepository.

func NewAccountSettingsRepository

func NewAccountSettingsRepository(db *sql.DB) *AccountSettingsRepository

NewAccountSettingsRepository - the account settings repository on db.

func (*AccountSettingsRepository) Get

Get - the account settings (registration, avatars, two-factor, the account emails) from their single row.

func (*AccountSettingsRepository) Update

Update saves s into the account settings row.

type BlockRepository

type BlockRepository struct {
	// contains filtered or unexported fields
}

BlockRepository is the ent adapter for entity.BlockRepository.

func NewBlockRepository

func NewBlockRepository(client *generated.Client) *BlockRepository

NewBlockRepository - the block repository on client.

func (BlockRepository) BlockByID

func (r BlockRepository) BlockByID(ctx context.Context, id int) (*entity.BlockDef, error)

BlockByID - the block with id; ErrEntityNotFound if there is none.

func (BlockRepository) BlockByMachineName

func (r BlockRepository) BlockByMachineName(ctx context.Context, name string) (*entity.BlockDef, error)

BlockByMachineName - the block named name (entity.BlockDef.MachineName).

func (BlockRepository) Blocks

Blocks - see entity.BlockRepository.Blocks; by region, then weight.

func (BlockRepository) CopyPlacement

CopyPlacement creates a copy of p (any type: a custom block's placement points at the same block) - used to give a new theme the placements of the previous one.

func (BlockRepository) CreateBlock

CreateBlock creates the block and its single placement together; the caller wraps it in a UOW.

func (BlockRepository) CreateMenuPlacement

CreateMenuPlacement creates a menu-block placement (no BlockDef row - see entity.BlockPlacementDef.MenuID).

func (BlockRepository) CreatePluginPlacement

CreatePluginPlacement creates a plugin-block placement (no BlockDef row - see entity.PluginBlockID).

func (BlockRepository) CreateViewPlacement

CreateViewPlacement creates a View-block placement (no BlockDef row - see entity.BlockPlacementDef.ViewDisplayID).

func (BlockRepository) DeleteBlock

func (r BlockRepository) DeleteBlock(ctx context.Context, id int) error

DeleteBlock removes the block along with its placements (application-level cascade, not FK ON DELETE).

func (BlockRepository) DeletePlacement

func (r BlockRepository) DeletePlacement(ctx context.Context, placementID int) error

DeletePlacement removes one placement row directly (custom or plugin) - unlike DeleteBlock, never touches a BlockDef row.

func (BlockRepository) MachineNameTaken

func (r BlockRepository) MachineNameTaken(ctx context.Context, name string, excludeID int) (bool, error)

MachineNameTaken reports whether a block other than excludeID (0 - none) is named name.

func (BlockRepository) PlacementByBlockID

func (r BlockRepository) PlacementByBlockID(ctx context.Context, blockID int, theme string) (*entity.BlockPlacementDef, error)

PlacementByBlockID - the custom block's placement in theme; ErrEntityNotFound if it has none there.

func (BlockRepository) PlacementByID

func (r BlockRepository) PlacementByID(ctx context.Context, id int) (*entity.BlockPlacementDef, error)

PlacementByID returns any placement (custom/plugin/view/menu) by its own ID; PlacementByBlockID can't find plugin/view/menu placements, which have no owning BlockDef.

func (BlockRepository) PublishedPlacementsByRegion

func (r BlockRepository) PublishedPlacementsByRegion(ctx context.Context, theme string, region entity.Region) ([]entity.BlockWithPlacement, error)

PublishedPlacementsByRegion returns published placements for one region of one theme, weight-sorted - raw data for CacheService; per-page visibility is filtered per request (see entity.BlockRepository.PublishedPlacementsByRegion).

func (BlockRepository) ReorderPlacements

func (r BlockRepository) ReorderPlacements(ctx context.Context, updates []entity.BlockPlacementOrderUpdate) error

ReorderPlacements bulk-applies Region/Weight from the admin drag-and-drop list (one UpdateOneID call per row).

func (BlockRepository) SearchBlocks

func (r BlockRepository) SearchBlocks(ctx context.Context, query string, limit int) ([]entity.BlockDef, error)

SearchBlocks - see entity.BlockRepository.SearchBlocks.

func (BlockRepository) ThemeHasPlacements

func (r BlockRepository) ThemeHasPlacements(ctx context.Context, theme string) (bool, error)

ThemeHasPlacements reports whether the theme has any placement.

func (BlockRepository) UpdateBlock

func (r BlockRepository) UpdateBlock(ctx context.Context, b entity.BlockDef) (*entity.BlockDef, error)

UpdateBlock saves the block (one without a MachineName named from its title).

func (BlockRepository) UpdatePlacement

UpdatePlacement saves the placement's region, weight, title and visibility (a nil PluginConfig keeps the stored one) and returns it.

type BlockedBotRepository

type BlockedBotRepository struct {
	// contains filtered or unexported fields
}

BlockedBotRepository implements entity.BlockedBotRepository.

func NewBlockedBotRepository

func NewBlockedBotRepository(db *sql.DB) *BlockedBotRepository

NewBlockedBotRepository creates a new BlockedBotRepository.

func (*BlockedBotRepository) Create

func (r *BlockedBotRepository) Create(ctx context.Context, pattern, comment string) (*entity.BlockedBot, error)

Create inserts a new blocked bot pattern.

func (*BlockedBotRepository) Delete

func (r *BlockedBotRepository) Delete(ctx context.Context, id int) error

Delete removes a blocked bot by ID.

func (*BlockedBotRepository) List

List returns all blocked bot patterns, newest first.

type BlockedIPRepository

type BlockedIPRepository struct {
	// contains filtered or unexported fields
}

BlockedIPRepository implements entity.BlockedIPRepository.

func NewBlockedIPRepository

func NewBlockedIPRepository(db *sql.DB) *BlockedIPRepository

NewBlockedIPRepository creates a new BlockedIPRepository.

func (*BlockedIPRepository) Create

func (r *BlockedIPRepository) Create(ctx context.Context, ip, comment string) (*entity.BlockedIP, error)

Create inserts a new, permanent, manually-added blocked IP.

func (*BlockedIPRepository) Delete

func (r *BlockedIPRepository) Delete(ctx context.Context, id int) error

Delete removes a blocked IP by ID.

func (*BlockedIPRepository) List

List returns all blocked IP patterns, newest first.

type BreadcrumbRuleRepository struct {
	// contains filtered or unexported fields
}

BreadcrumbRuleRepository is the ent adapter for entity.BreadcrumbRuleRepository.

func NewBreadcrumbRuleRepository

func NewBreadcrumbRuleRepository(client *generated.Client) *BreadcrumbRuleRepository

NewBreadcrumbRuleRepository - the breadcrumb rule repository on client.

func (r BreadcrumbRuleRepository) BreadcrumbRuleByID(ctx context.Context, id int) (*entity.BreadcrumbRuleDef, error)

BreadcrumbRuleByID - the rule with id; ErrEntityNotFound if there is none.

BreadcrumbRules - see entity.BreadcrumbRuleRepository.BreadcrumbRules.

CreateBreadcrumbRule adds the rule d and returns it with its ID.

func (r BreadcrumbRuleRepository) DeleteBreadcrumbRule(ctx context.Context, id int) error

DeleteBreadcrumbRule deletes the rule with id.

UpdateBreadcrumbRule saves d over the rule d.ID and returns it.

func (r BreadcrumbRuleRepository) UpdateBreadcrumbRuleWeight(ctx context.Context, id, weight int) error

UpdateBreadcrumbRuleWeight sets only the rule's weight (its place in the order).

type CaptchaSettingsRepository

type CaptchaSettingsRepository struct {
	// contains filtered or unexported fields
}

CaptchaSettingsRepository implements entity.CaptchaSettingsRepository.

func NewCaptchaSettingsRepository

func NewCaptchaSettingsRepository(db *sql.DB) *CaptchaSettingsRepository

NewCaptchaSettingsRepository - the CAPTCHA settings repository on db.

func (*CaptchaSettingsRepository) Get

Get - the CAPTCHA settings from their single row; Forms holds the switches of the core's forms and of the modules' ones that were saved.

func (*CaptchaSettingsRepository) Update

Update saves the settings row (the secret key sealed), creating it if it isn't there.

type CommentRepository

type CommentRepository struct {
	// contains filtered or unexported fields
}

CommentRepository provides database access to comments.

func NewCommentRepository

func NewCommentRepository(client *generated.Client) *CommentRepository

NewCommentRepository - the comment repository on client.

func (CommentRepository) ByCreatedByPaginated

func (r CommentRepository) ByCreatedByPaginated(ctx context.Context, userID int, status int8, limit int, offset int) (entity.Comments, error)

ByCreatedByPaginated returns user's comments ordered by CreatedAt desc

func (CommentRepository) ByID

func (r CommentRepository) ByID(ctx context.Context, id int) (*entity.Comment, error)

ByID returns comment by ID

func (CommentRepository) ByNodeID

func (r CommentRepository) ByNodeID(ctx context.Context, nid int, status int8) (entity.Comments, error)

ByNodeID returns all comments for a specific node (with hierarchy)

func (CommentRepository) ByNodeIDPaginated

func (r CommentRepository) ByNodeIDPaginated(ctx context.Context, nid int, status int8, limit int, offset int) (entity.Comments, error)

ByNodeIDPaginated returns paginated comments in threaded order (materialized path). Single query with ORDER BY path - exactly limit comments per page.

func (CommentRepository) CountByNodeID

func (r CommentRepository) CountByNodeID(ctx context.Context, nid int, status int8, rootOnly bool) (int, error)

CountByNodeID returns count of comments for a node If rootOnly is true, counts only root comments (without parent)

func (CommentRepository) CountByNodeIDs

func (r CommentRepository) CountByNodeIDs(ctx context.Context, nids []int, status int8, rootOnly bool) (map[int]int, error)

CountByNodeIDs returns comment counts for multiple nodes in a single query.

func (CommentRepository) CountCommentsWithPathLEQ

func (r CommentRepository) CountCommentsWithPathLEQ(ctx context.Context, nid int, status int8, path string) (int, error)

CountCommentsWithPathLEQ returns count of comments with path <= given path (for same nid, status)

func (CommentRepository) Create

Create creates a new comment and its materialized path (the parent's path plus its own ID) in one transaction (the caller's when ctx carries one): a reply never ends up a root.

func (CommentRepository) Delete

func (r CommentRepository) Delete(ctx context.Context, id int) error

Delete deletes a comment by ID Delete removes the comment and all its replies in one statement.

func (CommentRepository) DeleteByNodeID

func (r CommentRepository) DeleteByNodeID(ctx context.Context, nodeID int) error

DeleteByNodeID deletes every comment on the node.

func (CommentRepository) DescendantIDs

func (r CommentRepository) DescendantIDs(ctx context.Context, id int) ([]int, error)

DescendantIDs walks the reply tree by parent_id, level by level (the materialized path may be missing on imported comments).

func (CommentRepository) Find

Find returns comments with filters

func (CommentRepository) GetCommentPath

func (r CommentRepository) GetCommentPath(ctx context.Context, commentID int) (string, error)

GetCommentPath returns the materialized path for a comment

func (CommentRepository) GetLatestComments

func (r CommentRepository) GetLatestComments(ctx context.Context, limit int, status int8, excludeTypes []string) (entity.Comments, error)

GetLatestComments returns the latest comments of every node type except those whose comments are a discussion of their own (a forum topic's, entity.OwnDiscussionNodeTypes), on public content only. Only the essential fields, no user relations.

func (CommentRepository) HasDuplicate

func (r CommentRepository) HasDuplicate(ctx context.Context, authorID int, content string, since time.Time) (bool, error)

HasDuplicate - see entity.CommentsRepository.HasDuplicate.

func (CommentRepository) ListForAdmin

ListForAdmin returns all comments for admin list with pagination and configurable sort.

func (CommentRepository) ListRecentPublished

func (r CommentRepository) ListRecentPublished(ctx context.Context, status int8, excludeTypes []string, limit int, offset int) (entity.Comments, int, error)

ListRecentPublished returns published comments site-wide (including forum) on public content, except on nodes of excludeTypes, newest first, with total count.

func (CommentRepository) NodeIDsByAuthor

func (r CommentRepository) NodeIDsByAuthor(ctx context.Context, userID int) ([]int, error)

NodeIDsByAuthor - see entity.CommentsRepository.NodeIDsByAuthor.

func (CommentRepository) SetStatus

func (r CommentRepository) SetStatus(ctx context.Context, id int, status int8, reason string) error

SetStatus - see entity.CommentsRepository.SetStatus.

func (CommentRepository) SpamBefore

func (r CommentRepository) SpamBefore(ctx context.Context, before time.Time) ([]int, error)

SpamBefore - see entity.CommentsRepository.SpamBefore.

func (CommentRepository) TotalCount

func (r CommentRepository) TotalCount(ctx context.Context, filter entity.CommentsFilter) (int, error)

TotalCount returns total count of comments with filters

func (CommentRepository) Update

Update updates an existing comment

type CommentSettingsRepository

type CommentSettingsRepository struct {
	// contains filtered or unexported fields
}

CommentSettingsRepository implements entity.CommentSettingsRepository. Read on every comment form and post (several times a post), the row is kept after the first read until the repository writes it (afterWrite).

func NewCommentSettingsRepository

func NewCommentSettingsRepository(db *sql.DB) *CommentSettingsRepository

NewCommentSettingsRepository creates a CommentSettingsRepository.

func (*CommentSettingsRepository) Get

Get - see entity.CommentSettingsRepository.Get; outside a transaction, the settings kept since the last write.

func (*CommentSettingsRepository) Update

Update saves the settings row, creating it if it isn't there.

type ContentTypeRepository

type ContentTypeRepository struct {
	// contains filtered or unexported fields
}

ContentTypeRepository is the ent adapter for entity.ContentTypeRepository (runtime content type builder; for the field storage/instance split see entity/field_storage.go).

func NewContentTypeRepository

func NewContentTypeRepository(client *generated.Client) *ContentTypeRepository

NewContentTypeRepository - the content type repository on client.

func (ContentTypeRepository) AttachExistingField

func (r ContentTypeRepository) AttachExistingField(ctx context.Context, contentTypeID, fieldStorageID int, label string, required bool, sortOrder int) (*entity.FieldInstanceDef, error)

AttachExistingField creates only a FieldInstanceDef for an existing FieldStorageDef. The new instance gets the same visibility defaults as CreateField (shown on the detail page with its label).

func (ContentTypeRepository) ContentTypeByID

func (r ContentTypeRepository) ContentTypeByID(ctx context.Context, id int) (*entity.ContentTypeDef, error)

ContentTypeByID - the content type with id; ErrEntityNotFound if there is none.

func (ContentTypeRepository) ContentTypeByMachineName

func (r ContentTypeRepository) ContentTypeByMachineName(ctx context.Context, machineName string) (*entity.ContentTypeDef, error)

ContentTypeByMachineName - the content type named machineName; ErrEntityNotFound if there is none.

func (ContentTypeRepository) ContentTypes

ContentTypes - see entity.ContentTypeRepository.ContentTypes; by label.

func (ContentTypeRepository) CountFieldValues

func (r ContentTypeRepository) CountFieldValues(ctx context.Context, contentTypeID, fieldID int, fieldType entity.ContentTypeFieldType, multiple bool) (int, error)

CountFieldValues counts stored values of the field on nodes of this content type only (for the confirmation shown before detaching it). fieldID is the shared FieldStorageDef.ID, so contentTypeID is required to exclude values of other content types using the same field.

func (ContentTypeRepository) CreateContentType

CreateContentType adds the content type ct (settings the create form doesn't send keep their column defaults) and returns it with its ID.

func (ContentTypeRepository) CreateField

CreateField creates a new FieldStorageDef (the machine name must be globally unique; the service layer handles duplicate-key errors) and a FieldInstanceDef pointing at it. Both inserts share a transaction when the caller wraps them in entity.UnitOfWork.Do (GetClient picks up the tx client from ctx).

func (ContentTypeRepository) DeleteContentType

func (r ContentTypeRepository) DeleteContentType(ctx context.Context, id int) error

DeleteContentType deletes the type and its field instances (groups among them, and their form and display settings) - field_instances has no cascade on content_type_id. Each field goes as DeleteField does, so a storage nothing else uses leaves the catalog. Run it in a transaction: outside one, a failure halfway leaves some fields gone and the type in place.

func (ContentTypeRepository) DeleteField

func (r ContentTypeRepository) DeleteField(ctx context.Context, id int) error

DeleteField removes one content type's instance of a field. The shared FieldStorageDef stays in the reusable catalog while another instance or anything else holds it (FieldStorageUsage); with the last instance of an unused storage it goes too. field_value_*.field_id is the shared storage ID, so value rows are deleted only for nodes of this field's content type - otherwise the values of every other content type using the field would be wiped too.

func (ContentTypeRepository) FieldByID

FieldByID - the field instance with id, with its storage; ErrEntityNotFound if there is none.

func (ContentTypeRepository) FieldDateValuesForNodes

func (r ContentTypeRepository) FieldDateValuesForNodes(ctx context.Context, fieldStorageID int, nodeIDs []int) (map[int]time.Time, error)

FieldDateValuesForNodes - a date field's start per node; a node with several dates - the nearest not ended yet (by now in the site's zone), all ended - the latest: what a View sorts by.

func (ContentTypeRepository) FieldInstanceLabelsByFieldStorageIDs

func (r ContentTypeRepository) FieldInstanceLabelsByFieldStorageIDs(ctx context.Context, fieldStorageIDs []int) (map[int]string, error)

FieldInstanceLabelsByFieldStorageIDs - see entity.ContentTypeRepository for why field_storages has no label. First instance (by id) wins per field_storage_id, which is deterministic and favors no content type.

func (ContentTypeRepository) FieldNumberValuesForNodes

func (r ContentTypeRepository) FieldNumberValuesForNodes(ctx context.Context, fieldStorageID int, nodeIDs []int) (map[int]float64, error)

FieldNumberValuesForNodes - a number field's value per node, for the nodes among nodeIDs that have one (see entity.ContentTypeRepository.FieldTextValuesForNodes).

func (ContentTypeRepository) FieldSets

FieldSets - see entity.ContentTypeRepository.FieldSets.

func (ContentTypeRepository) FieldStorageByID

func (r ContentTypeRepository) FieldStorageByID(ctx context.Context, id int) (*entity.FieldStorageDef, error)

FieldStorageByID - see entity.ContentTypeRepository.FieldStorageByID.

func (ContentTypeRepository) FieldStorageUsage

func (r ContentTypeRepository) FieldStorageUsage(ctx context.Context, storageID int) (entity.FieldStorageUsage, error)

FieldStorageUsage counts what still holds the storage: its instances, Views (fields, filters, sorts, carousel link and glossary displays), breadcrumb rules and SEO rules.

func (ContentTypeRepository) FieldStorages

FieldStorages returns the whole catalog of reusable fields, for the "add existing field" picker.

func (ContentTypeRepository) FieldTaxonomyMultiValuesForNodes

func (r ContentTypeRepository) FieldTaxonomyMultiValuesForNodes(ctx context.Context, fieldStorageID int, nodeIDs []int) (map[int][]int, error)

FieldTaxonomyMultiValuesForNodes is FieldTaxonomyValuesForNodes for a Multiple() taxonomy field: node_id -> all its term IDs, read from field_value_taxonomy_multi. Used by hub routes that match a node against several term IDs and by detail-page rendering of multi-value fields.

func (ContentTypeRepository) FieldTaxonomyValuesForNodes

func (r ContentTypeRepository) FieldTaxonomyValuesForNodes(ctx context.Context, fieldStorageID int, nodeIDs []int) (map[int]int, error)

FieldTaxonomyValuesForNodes - see entity.ContentTypeRepository.FieldTaxonomyValuesForNodes.

func (ContentTypeRepository) FieldTextValuesForNodes

func (r ContentTypeRepository) FieldTextValuesForNodes(ctx context.Context, fieldStorageID int, nodeIDs []int) (map[int]string, error)

FieldTextValuesForNodes - see entity.ContentTypeRepository.FieldTextValuesForNodes.

func (ContentTypeRepository) FieldValues

func (r ContentTypeRepository) FieldValues(ctx context.Context, nodeID int, fields entity.FieldInstanceDefs) (map[int]any, error)

FieldValues - a node's value per field (fieldValues: one query per value table, taxonomy fields too). A field never set for this node is simply absent from the map - not an error.

func (ContentTypeRepository) FieldValuesForNodes

func (r ContentTypeRepository) FieldValuesForNodes(ctx context.Context, nodeIDs []int, fields entity.FieldInstanceDefs) (map[int]map[int]any, error)

FieldValuesForNodes - the values of fields for each of nodeIDs (node → field instance ID → value), one query per value table over all the fields and nodes: text, number, date (a time.Time, or an entity.DateValue for a field with a time or an end), bool, image and file (the file ID - the caller resolves files in one batch), list and reference (one value or, Multiple(), a slice in the order saved), link ([]entity.Link in the order saved, whatever the cardinality), user ([]int user IDs, likewise), blocks ([]int item IDs, likewise). Taxonomy fields go through FieldTaxonomy(Multi)ValuesForNodes; other types are skipped.

func (ContentTypeRepository) FieldsByContentTypeID

func (r ContentTypeRepository) FieldsByContentTypeID(ctx context.Context, contentTypeID int) (entity.FieldInstanceDefs, error)

FieldsByContentTypeID - the type's fields with their storages, by sort order, then ID.

func (ContentTypeRepository) NodesWithSeveralFieldValues

func (r ContentTypeRepository) NodesWithSeveralFieldValues(ctx context.Context, storage entity.FieldStorageDef) ([]int, error)

NodesWithSeveralFieldValues - the nodes holding more than one value of a multi-value field (they block making it single-valued), sorted by ID.

func (ContentTypeRepository) RichTextFieldStorageIDs

func (r ContentTypeRepository) RichTextFieldStorageIDs(ctx context.Context, fieldStorageIDs []int) (map[int]bool, error)

RichTextFieldStorageIDs - see entity.ContentTypeRepository.

func (ContentTypeRepository) SetFieldMultiple

func (r ContentTypeRepository) SetFieldMultiple(ctx context.Context, storageID int, multiple bool) error

SetFieldMultiple switches a field storage between one and several values per node: its values move to the other value table, its config gets "multiple" (a single-valued reference loses "symmetric"), and each instance's widget that the new cardinality doesn't allow is replaced (cardinalityWidget). The caller makes sure no node has several values before making a field single-valued (NodesWithSeveralFieldValues), in the same transaction: it writes several tables.

func (ContentTypeRepository) SetFieldValues

func (r ContentTypeRepository) SetFieldValues(ctx context.Context, nodeID int, fields entity.FieldInstanceDefs, values map[int]any, textFormats map[int]int) error

SetFieldValues replaces each field's values of the node with its value in values (absent - none) and, a text, its text format: through the store of the field's type (fieldStoreOf), its rows keyed by the shared FieldStorageID (not the per-type instance ID). The search index gets the fields' words again.

func (ContentTypeRepository) TextFormatIDsByNode

func (r ContentTypeRepository) TextFormatIDsByNode(ctx context.Context, nodeID int, fields entity.FieldInstanceDefs) (map[int]int, error)

TextFormatIDsByNode returns, for fields with non-empty AllowedTextFormatIDs(), the TextFormatDef each existing value was saved with, so the edit form can preselect it: one query for all of them, none if the content type doesn't use formats.

func (ContentTypeRepository) UpdateContentType

UpdateContentType saves ct's settings over the type ct.ID (its machine name stays) and returns it.

func (ContentTypeRepository) UpdateField

UpdateField updates FieldStorageDef.Config (shared by every content type using the field) and the instance's Label/Required/HiddenInForm/ DefaultImageID/UsableInForm/UsableInDetail/Config (the per-type WidgetConfig). It never touches SortOrder/FormGroupID (UpdateFieldSortOrder) or ShowOnDetail/ShowLabel/DisplayOrder/ DetailImageStyle/ParentGroupID (UpdateFieldDetailDisplay): disjoint write paths keep one admin tab from clobbering another's settings.

func (ContentTypeRepository) UpdateFieldDetailDisplay

func (r ContentTypeRepository) UpdateFieldDetailDisplay(ctx context.Context, fieldID int, d entity.FieldDetailDisplay) error

UpdateFieldDetailDisplay updates the detail-page display settings, including ParentGroupID (see UpdateField for why it is separate).

func (ContentTypeRepository) UpdateFieldSortOrder

func (r ContentTypeRepository) UpdateFieldSortOrder(ctx context.Context, fieldID int, sortOrder int, formGroupID *int) error

UpdateFieldSortOrder updates the form field order and FormGroupID from the fields tab drag-and-drop table (see UpdateField for why it is separate). FormGroupID is also set per field via UpdateField; this path updates it in bulk when an admin drags a field into a form group.

type DashboardRepository

type DashboardRepository struct {
	// contains filtered or unexported fields
}

DashboardRepository - entity.DashboardRepository: counts over the nodes, comments, users and node_counter.

func NewDashboardRepository

func NewDashboardRepository(db *sql.DB) *DashboardRepository

NewDashboardRepository creates a DashboardRepository.

func (*DashboardRepository) OnModeration

func (r *DashboardRepository) OnModeration(ctx context.Context) (int, error)

OnModeration - see entity.DashboardRepository.OnModeration.

func (*DashboardRepository) Popular

Popular - entity.DashboardRepository.Popular: a day's and all views from node_counter, a week's and a month's summed from node_view_days.

func (*DashboardRepository) Stats

func (r *DashboardRepository) Stats(ctx context.Context, since, today time.Time) (entity.DashboardStats, error)

Stats - see entity.DashboardRepository.Stats.

type DateFormatRepository

type DateFormatRepository struct {
	// contains filtered or unexported fields
}

DateFormatRepository manages the date_formats catalog.

func NewDateFormatRepository

func NewDateFormatRepository(db *sql.DB) *DateFormatRepository

NewDateFormatRepository - the date format repository on db.

func (*DateFormatRepository) CreateDateFormat

func (r *DateFormatRepository) CreateDateFormat(ctx context.Context, f entity.DateFormat) (int, error)

CreateDateFormat adds the date format f and returns its ID.

func (*DateFormatRepository) DateFormatByID

func (r *DateFormatRepository) DateFormatByID(ctx context.Context, id int) (*entity.DateFormat, error)

DateFormatByID - the date format with id.

func (*DateFormatRepository) DateFormatUsage

func (r *DateFormatRepository) DateFormatUsage(ctx context.Context, machineName string) ([]string, error)

DateFormatUsage - see entity.DateFormatRepository.DateFormatUsage.

func (*DateFormatRepository) DateFormats

func (r *DateFormatRepository) DateFormats(ctx context.Context) ([]entity.DateFormat, error)

DateFormats - every date format, by label, then ID.

func (*DateFormatRepository) DeleteDateFormat

func (r *DateFormatRepository) DeleteDateFormat(ctx context.Context, id int) error

DeleteDateFormat deletes the date format with id.

func (*DateFormatRepository) InstanceDateFormats

func (r *DateFormatRepository) InstanceDateFormats(ctx context.Context) (map[string]string, error)

InstanceDateFormats - see entity.DateFormatRepository.InstanceDateFormats.

func (*DateFormatRepository) UpdateDateFormat

func (r *DateFormatRepository) UpdateDateFormat(ctx context.Context, f entity.DateFormat) error

UpdateDateFormat updates label and pattern; the machine name never changes.

type DynamicContentRepository

type DynamicContentRepository struct {
	// contains filtered or unexported fields
}

DynamicContentRepository - the nodes of one content type: the node row and its field values (entity.ContentTypeRepository's generic SetFieldValues/FieldValues, not a per-type ent entity). Built per request (NewDynamicContentRepositoryFactory): admin-created types are dynamic, and the struct is cheap.

func NewDynamicContentRepository

func NewDynamicContentRepository(
	client *generated.Client,
	contentTypeRepo entity.ContentTypeRepository,
	taxonomyRepo entity.TaxonomyRepository,
	def entity.ContentTypeDef,
	fields entity.FieldInstanceDefs,
) *DynamicContentRepository

NewDynamicContentRepository - the repository of the nodes of the content type def with its fields: their values go through contentTypeRepo, the terms a node is loaded with come from taxonomyRepo.

func (DynamicContentRepository) ByNodeID

ByNodeID - the node with its field values, terms and text formats.

func (DynamicContentRepository) Create

Create persists a new node row plus its field values, in one transaction (the caller's unit of work when ctx carries one): a failed value leaves no node.

func (DynamicContentRepository) Update

Update saves the node's field values, then its own fields (title, slug, publishing, comment mode, flags, the schedule; the author and the date when set - an administrator's override, zero leaves them) - in one transaction (the caller's when ctx carries one): a failure halfway leaves the node as it was, its values not deleted.

type EntUnitOfWork

type EntUnitOfWork struct {
	// contains filtered or unexported fields
}

EntUnitOfWork implements entity.UnitOfWork with ent transactions.

func NewUnitOfWork

func NewUnitOfWork(client *generated.Client) *EntUnitOfWork

NewUnitOfWork - the unit of work running its transactions on client.

func (*EntUnitOfWork) Do

func (u *EntUnitOfWork) Do(ctx context.Context, fn func(ctx context.Context) error) error

Do runs fn in a transaction: the repositories fn calls (GetClient) write in it, and it commits when fn succeeds. Inside another unit of work, or with a transaction's client, fn joins that transaction: a second one on another connection would not see its rows and could wait on its locks.

type FileFocalPoints

type FileFocalPoints struct {
	Files  entity.FileRepository
	Scheme string
}

FileFocalPoints implements imagestyle.FocalPoints over the files table: the focal point of the file stored at Scheme + key (public://, private://).

func (FileFocalPoints) FocalPoint

func (f FileFocalPoints) FocalPoint(ctx context.Context, key string) (*imagestyle.FocalPoint, error)

FocalPoint - the focal point of the file stored under key (as a share of its width and height); nil when the file isn't known or has none.

type FileRepository

type FileRepository struct {
	// contains filtered or unexported fields
}

FileRepository is the ent-backed entity.FileRepository.

func NewFileRepository

func NewFileRepository(fileClient *generated.FileClient) *FileRepository

NewFileRepository - the file repository on fileClient.

func (FileRepository) ByID

func (r FileRepository) ByID(ctx context.Context, id int) (*entity.File, error)

ByID resolves a file by its id.

func (FileRepository) ByIDs

func (r FileRepository) ByIDs(ctx context.Context, ids []int) (map[int]entity.File, error)

ByIDs resolves multiple files in one query, keyed by id.

func (FileRepository) ByURI

func (r FileRepository) ByURI(ctx context.Context, uri string) (*entity.File, error)

ByURI resolves a file by its URI (the first row of several sharing it).

func (FileRepository) Create

func (r FileRepository) Create(
	ctx context.Context,
	uri, mimeType string,
	width, height, sizeBytes int,
	createdBy int,
) (*entity.File, error)

Create creates a new File record.

func (FileRepository) SetFocal

func (r FileRepository) SetFocal(ctx context.Context, id int, focal *entity.FocalPoint) error

SetFocal sets a file's focal point (see entity.FileRepository.SetFocal).

func (FileRepository) SetOriginalFilename

func (r FileRepository) SetOriginalFilename(ctx context.Context, id int, name string) error

SetOriginalFilename sets a file's OriginalFilename (see entity.FileRepository.SetOriginalFilename).

func (FileRepository) UpdateAlt

func (r FileRepository) UpdateAlt(ctx context.Context, id int, alt string) error

UpdateAlt sets a file's alt text (see entity.FileRepository.UpdateAlt).

type ImageStyleRepository

type ImageStyleRepository struct {
	// contains filtered or unexported fields
}

ImageStyleRepository is the ent adapter for entity.ImageStyleRepository.

func NewImageStyleRepository

func NewImageStyleRepository(client *generated.Client) *ImageStyleRepository

NewImageStyleRepository - the image style repository on client.

func (ImageStyleRepository) CreateImageStyle

CreateImageStyle adds the image style s and returns it with its ID.

func (ImageStyleRepository) DeleteImageStyle

func (r ImageStyleRepository) DeleteImageStyle(ctx context.Context, id int) error

DeleteImageStyle deletes the image style with id; ErrEntityNotFound if there is none.

func (ImageStyleRepository) ImageStyleByID

func (r ImageStyleRepository) ImageStyleByID(ctx context.Context, id int) (*entity.ImageStyleDef, error)

ImageStyleByID - the image style with id; ErrEntityNotFound if there is none.

func (ImageStyleRepository) ImageStyleByName

func (r ImageStyleRepository) ImageStyleByName(ctx context.Context, name string) (*entity.ImageStyleDef, error)

ImageStyleByName - the image style named name; ErrEntityNotFound if there is none.

func (ImageStyleRepository) ImageStyles

ImageStyles - every image style, by name.

func (ImageStyleRepository) UpdateImageStyle

UpdateImageStyle never touches Name: URLs and Go call sites reference a style by name, so renaming would silently break them.

type ImageStyleRepositoryAdapter

type ImageStyleRepositoryAdapter struct {
	// contains filtered or unexported fields
}

ImageStyleRepositoryAdapter implements pkg/imagestyle.ImageStyleRepository (context-free) on top of the DB-backed entity.ImageStyleRepository, so the resize/serve pipeline (imagestyle.StyleService) resolves styles managed in the admin UI.

func NewImageStyleRepositoryAdapter

func NewImageStyleRepositoryAdapter(repo entity.ImageStyleRepository) *ImageStyleRepositoryAdapter

NewImageStyleRepositoryAdapter - the adapter resolving styles through repo.

func (*ImageStyleRepositoryAdapter) FindByName

FindByName - the style named name for the resize pipeline; imagestyle.ErrStyleNotFound if there is none.

type IntegrationSettingsRepository

type IntegrationSettingsRepository struct {
	// contains filtered or unexported fields
}

IntegrationSettingsRepository - counters and codes (one row).

func NewIntegrationSettingsRepository

func NewIntegrationSettingsRepository(db *sql.DB) *IntegrationSettingsRepository

NewIntegrationSettingsRepository - the integration settings repository on db.

func (*IntegrationSettingsRepository) Get

Get - the counters, codes and consent settings from their single row.

func (*IntegrationSettingsRepository) Update

Update saves s into the integration settings row.

type InterfacePackRepository

type InterfacePackRepository struct {
	// contains filtered or unexported fields
}

InterfacePackRepository - entity.InterfacePackRepository on ent: the packs in interface_packs, their strings in interface_strings (origin "pack").

func NewInterfacePackRepository

func NewInterfacePackRepository(db *sql.DB) *InterfacePackRepository

NewInterfacePackRepository - the repository on db.

func NewInterfacePackRepositoryOn

func NewInterfacePackRepositoryOn(client *generated.Client) *InterfacePackRepository

NewInterfacePackRepositoryOn - the repository on client: for a caller with a client of its database (its dialect), not the app's.

func (*InterfacePackRepository) Delete

func (r *InterfacePackRepository) Delete(ctx context.Context, lang string) error

Delete - see entity.InterfacePackRepository.Delete.

func (*InterfacePackRepository) Install

Install - see entity.InterfacePackRepository.Install.

func (*InterfacePackRepository) Packs

Packs - see entity.InterfacePackRepository.Packs.

func (*InterfacePackRepository) Strings

Strings - see entity.InterfacePackRepository.Strings.

type InterfaceStringRepository

type InterfaceStringRepository struct {
	// contains filtered or unexported fields
}

InterfaceStringRepository - entity.InterfaceStringRepository on ent.

func NewInterfaceStringRepository

func NewInterfaceStringRepository(db *sql.DB) *InterfaceStringRepository

NewInterfaceStringRepository - the repository on db.

func (*InterfaceStringRepository) All

All - see entity.InterfaceStringRepository.All.

func (*InterfaceStringRepository) Delete

func (r *InterfaceStringRepository) Delete(ctx context.Context, lang, msgctx, source string) error

Delete - see entity.InterfaceStringRepository.Delete.

func (*InterfaceStringRepository) Save

Save - see entity.InterfaceStringRepository.Save.

type MailLogRepository

type MailLogRepository struct {
	// contains filtered or unexported fields
}

MailLogRepository implements entity.MailLogRepository.

func NewMailLogRepository

func NewMailLogRepository(db *sql.DB) *MailLogRepository

NewMailLogRepository creates a new MailLogRepository.

func (*MailLogRepository) Add

Add records an email (its address, subject and error cut to the columns).

func (*MailLogRepository) DeleteBefore

func (r *MailLogRepository) DeleteBefore(ctx context.Context, t time.Time) error

DeleteBefore removes the entries older than t.

func (*MailLogRepository) LastSent

func (r *MailLogRepository) LastSent(ctx context.Context) (map[string]time.Time, error)

LastSent - when each email (by key) was last sent.

func (*MailLogRepository) List

List - the entries f asks for, newest first, and how many there are.

type MailSettingsRepository

type MailSettingsRepository struct {
	// contains filtered or unexported fields
}

MailSettingsRepository implements entity.MailSettingsRepository.

func NewMailSettingsRepository

func NewMailSettingsRepository(db *sql.DB) *MailSettingsRepository

NewMailSettingsRepository - the mail settings repository on db.

func (*MailSettingsRepository) Get

Get - the mail settings from their single row, with the modules' ways of sending's settings (mail_transport_settings).

func (*MailSettingsRepository) Update

Update saves the settings row (the secrets sealed), creating it if it isn't there, and replaces the transports' settings with s's (every value sealed; an empty one isn't kept).

type MailTemplateRepository

type MailTemplateRepository struct {
	// contains filtered or unexported fields
}

MailTemplateRepository implements entity.MailTemplateRepository.

func NewMailTemplateRepository

func NewMailTemplateRepository(db *sql.DB) *MailTemplateRepository

NewMailTemplateRepository creates a new MailTemplateRepository.

func (*MailTemplateRepository) All

All - the emails changed, by key.

func (*MailTemplateRepository) SaveText

SaveText stores an email's text (blank - the default's).

func (*MailTemplateRepository) SetEnabled

func (r *MailTemplateRepository) SetEnabled(ctx context.Context, key string, on bool) error

SetEnabled switches an email on or off.

type MaintenanceRepository

type MaintenanceRepository struct {
	// contains filtered or unexported fields
}

MaintenanceRepository implements entity.MaintenanceRepository.

func NewMaintenanceRepository

func NewMaintenanceRepository(db *sql.DB) *MaintenanceRepository

NewMaintenanceRepository creates a new MaintenanceRepository.

func (*MaintenanceRepository) Get

Get returns the maintenance settings (single row).

func (*MaintenanceRepository) Update

Update saves the maintenance settings.

type MediaRepository

type MediaRepository struct {
	// contains filtered or unexported fields
}

MediaRepository implements entity.MediaRepository: the files table with the places that use its files - the file and image fields, the types' default images and the modules' tables of files (migrations.FileColumns; entity.Module.NodeFiles name their content).

func NewMediaRepository

func NewMediaRepository(db *sql.DB) *MediaRepository

NewMediaRepository - the media repository on db.

func (*MediaRepository) MediaFiles

func (r *MediaRepository) MediaFiles(ctx context.Context, f entity.MediaFilter) ([]entity.File, int, error)

MediaFiles - see entity.MediaRepository.MediaFiles.

func (*MediaRepository) MediaTotals

func (r *MediaRepository) MediaTotals(ctx context.Context) (entity.MediaTotals, error)

MediaTotals - how many files there are and their size in all.

func (*MediaRepository) MediaUploaders

func (r *MediaRepository) MediaUploaders(ctx context.Context) ([]entity.User, error)

MediaUploaders - see entity.MediaRepository.MediaUploaders.

func (*MediaRepository) MediaUseCounts

func (r *MediaRepository) MediaUseCounts(ctx context.Context, fileIDs []int) (map[int]int, error)

MediaUseCounts - see entity.MediaRepository.MediaUseCounts.

func (*MediaRepository) MediaUses

func (r *MediaRepository) MediaUses(ctx context.Context, fileID int) ([]entity.MediaUse, error)

MediaUses - see entity.MediaRepository.MediaUses.

type MenuRepository struct {
	// contains filtered or unexported fields
}

MenuRepository is the ent adapter for entity.MenuRepository.

func NewMenuRepository

func NewMenuRepository(client *generated.Client) *MenuRepository

NewMenuRepository - the menu repository on client.

func (r MenuRepository) CreateMenu(ctx context.Context, m entity.MenuDef) (*entity.MenuDef, error)

CreateMenu adds the menu m and returns it with its ID.

func (r MenuRepository) CreateMenuLink(ctx context.Context, l entity.MenuLinkDef) (*entity.MenuLinkDef, error)

CreateMenuLink adds the menu link l and returns it with its ID.

func (r MenuRepository) DeleteMenu(ctx context.Context, id int) error

DeleteMenu removes the menu and all its links. This is an application-level cascade (fk_menu_links_menu has no ON DELETE CASCADE), so it runs two statements on the same tx-carrying ctx.

func (r MenuRepository) DeleteMenuLink(ctx context.Context, id int) error

DeleteMenuLink moves the deleted link's children up one level (to its ParentID) instead of relying on the FK's ON DELETE SET NULL, which would promote them all the way to the menu's top level.

func (r MenuRepository) MenuByID(ctx context.Context, id int) (*entity.MenuDef, error)

MenuByID - the menu with id; ErrEntityNotFound if there is none.

func (r MenuRepository) MenuByMachineName(ctx context.Context, machineName string) (*entity.MenuDef, error)

MenuByMachineName - the menu named machineName; ErrEntityNotFound if there is none.

func (r MenuRepository) MenuLinkByID(ctx context.Context, id int) (*entity.MenuLinkDef, error)

MenuLinkByID - the menu link with id; ErrEntityNotFound if there is none.

func (r MenuRepository) MenuLinksByMenuID(ctx context.Context, menuID int) (entity.MenuLinkDefs, error)

MenuLinksByMenuID - the menu's links, all levels in one flat list, by weight, then ID.

Menus - every menu, by label.

func (r MenuRepository) ReorderMenuLinks(ctx context.Context, updates []entity.MenuLinkOrderUpdate) error

ReorderMenuLinks bulk-applies Weight/ParentID from the admin drag-and-drop tree (one UpdateOneID call per row).

func (r MenuRepository) UpdateMenu(ctx context.Context, m entity.MenuDef) (*entity.MenuDef, error)

UpdateMenu never touches MachineName - identity strings are not renamed (same as TextFormatDef/ImageStyleDef).

func (r MenuRepository) UpdateMenuLink(ctx context.Context, l entity.MenuLinkDef) (*entity.MenuLinkDef, error)

UpdateMenuLink saves l over the link l.ID (its menu stays) and returns it; ErrEntityNotFound if there is none.

type ModuleRepository

type ModuleRepository struct {
	// contains filtered or unexported fields
}

ModuleRepository implements entity.ModuleRepository.

func NewModuleRepository

func NewModuleRepository(db *sql.DB) *ModuleRepository

NewModuleRepository - the module repository on db.

func (*ModuleRepository) CountRows

func (r *ModuleRepository) CountRows(ctx context.Context, table string) (int, error)

CountRows - rows in a module's data table (any table, so the query is built for it, quoted for the database).

func (r *ModuleRepository) DeleteMenuLinks(ctx context.Context, paths []string) error

DeleteMenuLinks - see entity.ModuleRepository.DeleteMenuLinks.

func (*ModuleRepository) DeletePluginPlacements

func (r *ModuleRepository) DeletePluginPlacements(ctx context.Context, ids []entity.PluginBlockID) error

DeletePluginPlacements removes the plugin blocks' placements, every theme.

func (*ModuleRepository) PluginPlacements

func (r *ModuleRepository) PluginPlacements(ctx context.Context, ids []entity.PluginBlockID) ([]entity.PluginPlacementRef, error)

PluginPlacements - where the plugin blocks are placed, every theme.

func (*ModuleRepository) SetEnabled

func (r *ModuleRepository) SetEnabled(ctx context.Context, name string, enabled bool) error

SetEnabled stores the module's state.

func (*ModuleRepository) States

func (r *ModuleRepository) States(ctx context.Context) (map[string]bool, error)

States - module name → enabled, for every module with a row.

type ModuleUninstallRepository

type ModuleUninstallRepository struct {
	// contains filtered or unexported fields
}

ModuleUninstallRepository - the core tables' side of a module's uninstall (service.ModuleUninstall): its content, the settings of its content types, the files only its tables use, a vocabulary it owns.

func NewModuleUninstallRepository

func NewModuleUninstallRepository(db *sql.DB) *ModuleUninstallRepository

NewModuleUninstallRepository creates a ModuleUninstallRepository.

func (*ModuleUninstallRepository) ClearFieldFormatters

func (r *ModuleUninstallRepository) ClearFieldFormatters(ctx context.Context, names []string) error

ClearFieldFormatters makes the fields shown by these formatters - on the detail page (field_instances.detail_formatter) and in Views (view_fields.formatter) - show as links again.

func (*ModuleUninstallRepository) DeleteMailTransportSettings

func (r *ModuleUninstallRepository) DeleteMailTransportSettings(ctx context.Context, transports []string) error

DeleteMailTransportSettings forgets the settings of the ways of sending (a module's) and, if the saved mail settings send through one of them, that choice: the server config's settings apply again.

func (*ModuleUninstallRepository) DeleteNodeTypeSettings

func (r *ModuleUninstallRepository) DeleteNodeTypeSettings(ctx context.Context, types []string) error

DeleteNodeTypeSettings removes what core settings keep for the content types: their search, SEO and breadcrumb rules; a block shown only on them loses them from its visibility, and is deleted when none is left (it showed on their pages only).

func (*ModuleUninstallRepository) DeleteViewCriteria

func (r *ModuleUninstallRepository) DeleteViewCriteria(ctx context.Context, prefix string) error

DeleteViewCriteria removes the Views' sort criteria, filters and fields whose key (builtin_field) starts with prefix: a module's.

func (*ModuleUninstallRepository) DeleteVocabularyIfUnused

func (r *ModuleUninstallRepository) DeleteVocabularyIfUnused(ctx context.Context, vid int) (bool, error)

DeleteVocabularyIfUnused deletes the vocabulary with its terms unless a taxonomy field, a search badge or a field value still uses it; reports whether it was deleted.

func (*ModuleUninstallRepository) FileIDs

func (r *ModuleUninstallRepository) FileIDs(ctx context.Context, columns [][2]string) ([]int, error)

FileIDs - the files the columns reference (each a table and a column of a module's tables, from its schema); none while the module isn't installed.

func (*ModuleUninstallRepository) NodeIDsOfTypes

func (r *ModuleUninstallRepository) NodeIDsOfTypes(ctx context.Context, types []string, limit int) ([]int, error)

NodeIDsOfTypes - up to limit IDs of nodes of the types, the trash's too.

func (*ModuleUninstallRepository) RemoveTextFilters

func (r *ModuleUninstallRepository) RemoveTextFilters(ctx context.Context, names []string) (map[int][]string, error)

RemoveTextFilters takes the filters out of the text formats that have them on; returns those formats' filters left, by ID.

type NodeCounterRepository

type NodeCounterRepository struct {
	// contains filtered or unexported fields
}

NodeCounterRepository implements entity.NodeCounterRepository.

func NewNodeCounterRepository

func NewNodeCounterRepository(db *sql.DB) *NodeCounterRepository

NewNodeCounterRepository creates a new NodeCounterRepository.

func (*NodeCounterRepository) DeleteViewDaysBefore

func (r *NodeCounterRepository) DeleteViewDaysBefore(ctx context.Context, day int) error

DeleteViewDaysBefore drops the views by day older than day.

func (*NodeCounterRepository) IncrementView

func (r *NodeCounterRepository) IncrementView(ctx context.Context, nid int) error

IncrementView counts a view of the node: its totals (incrementCounter) and its views of the site's day (node_view_days).

type NodeDeleteRepository

type NodeDeleteRepository struct {
	// contains filtered or unexported fields
}

NodeDeleteRepository implements entity.NodeDeleteRepository.

func NewNodeDeleteRepository

func NewNodeDeleteRepository(db *sql.DB) *NodeDeleteRepository

NewNodeDeleteRepository creates a new NodeDeleteRepository.

func (*NodeDeleteRepository) DeleteNode

func (r *NodeDeleteRepository) DeleteNode(ctx context.Context, nodeID int) error

DeleteNode deletes nodeID and everything attached to it in one transaction.

type NodeRepository

type NodeRepository struct {
	// contains filtered or unexported fields
}

NodeRepository provides database access to nodes.

func NewNodeRepository

func NewNodeRepository(client *generated.Client) *NodeRepository

NewNodeRepository - the node repository on client.

func (NodeRepository) AltTitles

func (r NodeRepository) AltTitles(ctx context.Context, nodes entity.Nodes) (map[int]string, error)

AltTitles - the alternative titles (their type's AltTitleField) of the nodes that have one, by node ID: ProfileMaterialDisplayTitle for a whole list, one query per content type instead of two per node.

func (NodeRepository) AnyWithViewRoles

func (r NodeRepository) AnyWithViewRoles(ctx context.Context) (bool, error)

AnyWithViewRoles reports whether some node has view roles of its own (entity.Node.ViewRoles), whoever asks.

func (NodeRepository) ByID

func (r NodeRepository) ByID(ctx context.Context, nodeID int) (*entity.Node, error)

ByID - the node with nodeID, with its author and view counter; ErrEntityNotFound if there is none.

func (NodeRepository) ByIDs

func (r NodeRepository) ByIDs(ctx context.Context, ids []int) (map[int]entity.Node, error)

ByIDs - the nodes among ids that exist, by ID: their own columns, no edges.

func (NodeRepository) BySlug

func (r NodeRepository) BySlug(ctx context.Context, slug string) (*entity.Node, error)

BySlug - the node with slug, with its author (and the author's role) and view counter; ErrEntityNotFound if there is none.

func (NodeRepository) ByType

func (r NodeRepository) ByType(ctx context.Context, nodeType string) (entity.Nodes, error)

ByType - the nodes of a type (ID and title), the newest first.

func (NodeRepository) ClearSchedule

func (r NodeRepository) ClearSchedule(ctx context.Context, nodeID int) error

ClearSchedule clears the node's scheduled publishing and unpublishing.

func (NodeRepository) CountByType

func (r NodeRepository) CountByType(ctx context.Context, nodeType string) (int, error)

CountByType counts all nodes of the given type (any status, the trash too), used to guard deleting or renaming a content type that still has nodes.

func (NodeRepository) CountPathNodes

func (r NodeRepository) CountPathNodes(ctx context.Context, nodeType string, onlyAuto bool) (int, error)

CountPathNodes - how many nodes of nodeType PathBatch goes through (onlyAuto - only those following their type's pattern).

func (NodeRepository) CountPublicSitemapNodes

func (r NodeRepository) CountPublicSitemapNodes(ctx context.Context, excludeTypes []string) (int, error)

CountPublicSitemapNodes - see entity.NodesRepository.CountPublicSitemapNodes.

func (NodeRepository) CreateRow

func (r NodeRepository) CreateRow(ctx context.Context, n entity.Node) (int, error)

CreateRow stores a new node's row: its type, title, slug, status, moderation, comment mode, author and dates (created now unless set); its title's words go to the search index.

func (NodeRepository) DueToPublish

func (r NodeRepository) DueToPublish(ctx context.Context, now time.Time) ([]int, error)

DueToPublish - see entity.NodeScheduleRepository.DueToPublish; the earliest due first.

func (NodeRepository) DueToUnpublish

func (r NodeRepository) DueToUnpublish(ctx context.Context, now time.Time) ([]int, error)

DueToUnpublish - the nodes whose scheduled unpublishing has come by now, the earliest due first.

func (NodeRepository) ListForAdmin

func (r NodeRepository) ListForAdmin(ctx context.Context, filter entity.AdminNodesFilter) (*entity.Nodes, int, error)

ListForAdmin returns nodes for the admin list with filters and pagination.

func (NodeRepository) ListForFeed

func (r NodeRepository) ListForFeed(ctx context.Context, filter entity.FeedNodeFilter) (entity.Nodes, error)

ListForFeed - see entity.NodesRepository.ListForFeed.

func (NodeRepository) ListPublicSitemapNodes

func (r NodeRepository) ListPublicSitemapNodes(ctx context.Context, excludeTypes []string, limit, offset int) ([]entity.SitemapNodeRow, error)

ListPublicSitemapNodes - see entity.NodesRepository.ListPublicSitemapNodes.

func (NodeRepository) PageSEO

func (r NodeRepository) PageSEO(ctx context.Context, nodeID int) (entity.PageSEO, error)

PageSEO - the node's own title and description (page_seo), empty without them.

func (NodeRepository) PathBatch

func (r NodeRepository) PathBatch(ctx context.Context, nodeType string, afterID, limit int, onlyAuto bool) (entity.Nodes, error)

PathBatch - see entity.NodesRepository.PathBatch.

func (NodeRepository) ProfileMaterialDisplayTitle

func (r NodeRepository) ProfileMaterialDisplayTitle(ctx context.Context, n entity.Node) string

ProfileMaterialDisplayTitle returns the node's alternative title (its type's AltTitleField) when set, else its title. Used by the Views title field and the modules' pages under a node.

func (NodeRepository) RestoreNode

func (r NodeRepository) RestoreNode(ctx context.Context, nodeID int) error

RestoreNode - see entity.NodeTrashRepository.RestoreNode.

func (NodeRepository) Schedule

Schedule - see entity.NodeScheduleRepository.Schedule.

func (NodeRepository) SearchByTitle

func (r NodeRepository) SearchByTitle(ctx context.Context, query string, types []string, limit int) ([]entity.NodeSearchHit, error)

SearchByTitle is a lightweight node search for pickers: no eager-loaded edges, since callers need only id/title/type/slug. Matches nodes.title or any short text field value (where alternative titles live), of public nodes only (published, not on moderation).

func (NodeRepository) SetLangcode

func (r NodeRepository) SetLangcode(ctx context.Context, nodeID int, code string) error

SetLangcode - see entity.NodesRepository.SetLangcode.

func (NodeRepository) SetPath

func (r NodeRepository) SetPath(ctx context.Context, nodeID int, slug string, auto bool) error

SetPath - see entity.NodesRepository.SetPath.

func (NodeRepository) SlugExists

func (r NodeRepository) SlugExists(ctx context.Context, slug string) (bool, error)

SlugExists reports whether a node has the slug (of any type, whoever asks - entity.WithAllNodeTypes: slugs are unique across all nodes).

func (NodeRepository) SlugExistsExcludingNode

func (r NodeRepository) SlugExistsExcludingNode(ctx context.Context, slug string, excludeNodeID int) (bool, error)

SlugExistsExcludingNode reports whether another node than excludeNodeID has the slug (of any type, whoever asks).

func (NodeRepository) TrashNode

func (r NodeRepository) TrashNode(ctx context.Context, nodeID, by int, at time.Time) error

TrashNode - see entity.NodeTrashRepository.TrashNode.

func (NodeRepository) TrashedBefore

func (r NodeRepository) TrashedBefore(ctx context.Context, before time.Time) ([]int, error)

TrashedBefore - see entity.NodeTrashRepository.TrashedBefore.

func (NodeRepository) TrashedNodes

func (r NodeRepository) TrashedNodes(ctx context.Context, limit, offset int) (entity.Nodes, int, error)

TrashedNodes - see entity.NodeTrashRepository.TrashedNodes.

func (NodeRepository) URLsByIDs

func (r NodeRepository) URLsByIDs(ctx context.Context, ids []int) (map[int]string, error)

URLsByIDs - see entity.NodesRepository.URLsByIDs.

func (NodeRepository) UpdateOnModeration

func (r NodeRepository) UpdateOnModeration(ctx context.Context, nodeID int, onModeration int) error

UpdateOnModeration sets whether the node waits on moderation (1) or not (0).

func (NodeRepository) UpdateRow

func (r NodeRepository) UpdateRow(ctx context.Context, n entity.Node) error

UpdateRow stores a node's row (CreateRow's columns), keeping its author and creation time when n doesn't set them; its title's words go to the search index.

func (NodeRepository) UpdateStatus

func (r NodeRepository) UpdateStatus(ctx context.Context, nodeID int, status int) error

UpdateStatus publishes (1) or unpublishes (0) the node; publishing clears its scheduled publishing, unpublishing its scheduled unpublishing (done, either way).

func (NodeRepository) UpsertPageSEO

func (r NodeRepository) UpsertPageSEO(ctx context.Context, nodeID int, metaTitle, metaDescription string) error

UpsertPageSEO - see entity.NodesRepository.UpsertPageSEO.

type NodeRevisionRepository

type NodeRevisionRepository struct {
	// contains filtered or unexported fields
}

NodeRevisionRepository - entity.NodeRevisionRepository on ent.

func NewNodeRevisionRepository

func NewNodeRevisionRepository(client *generated.Client) *NodeRevisionRepository

NewNodeRevisionRepository - the node revision repository on client.

func (NodeRevisionRepository) ByID

func (r NodeRevisionRepository) ByID(ctx context.Context, nodeID, id int) (*entity.NodeRevision, error)

ByID - see entity.NodeRevisionRepository.ByID.

func (NodeRevisionRepository) Create

Create stores the revision rev (its snapshot encoded) and returns its ID.

func (NodeRevisionRepository) Latest

Latest - see entity.NodeRevisionRepository.Latest.

func (NodeRevisionRepository) List

func (r NodeRevisionRepository) List(ctx context.Context, nodeID, offset, limit int) ([]entity.NodeRevision, int, error)

List - see entity.NodeRevisionRepository.List.

func (NodeRevisionRepository) Prune

func (r NodeRevisionRepository) Prune(ctx context.Context, nodeID, keep int) error

Prune - see entity.NodeRevisionRepository.Prune.

func (NodeRevisionRepository) Recent

Recent - see entity.NodeRevisionRepository.Recent.

type OAuthSettingsRepository

type OAuthSettingsRepository struct {
	// contains filtered or unexported fields
}

OAuthSettingsRepository implements entity.OAuthSettingsRepository.

func NewOAuthSettingsRepository

func NewOAuthSettingsRepository(db *sql.DB) *OAuthSettingsRepository

NewOAuthSettingsRepository - the OAuth settings repository on db.

func (*OAuthSettingsRepository) LinkedAccounts

func (r *OAuthSettingsRepository) LinkedAccounts(ctx context.Context) (map[string]int, error)

LinkedAccounts - see entity.OAuthSettingsRepository.LinkedAccounts.

func (*OAuthSettingsRepository) List

List - see entity.OAuthSettingsRepository.List.

func (*OAuthSettingsRepository) Upsert

Upsert saves a provider's row (the client secret sealed), creating it if it isn't there.

type PreviewLinkRepository

type PreviewLinkRepository struct {
	// contains filtered or unexported fields
}

PreviewLinkRepository - see entity.PreviewLinkRepository.

func NewPreviewLinkRepository

func NewPreviewLinkRepository(client *generated.Client) *PreviewLinkRepository

NewPreviewLinkRepository - the preview link repository on client.

func (r *PreviewLinkRepository) DeletePreviewLinks(ctx context.Context, nodeID int) error

DeletePreviewLinks - see entity.PreviewLinkRepository.DeletePreviewLinks.

func (*PreviewLinkRepository) PreviewLinkByHash

func (r *PreviewLinkRepository) PreviewLinkByHash(ctx context.Context, tokenHash string) (*entity.PreviewLink, error)

PreviewLinkByHash - see entity.PreviewLinkRepository.PreviewLinkByHash.

func (*PreviewLinkRepository) PreviewLinkOf

func (r *PreviewLinkRepository) PreviewLinkOf(ctx context.Context, nodeID int) (*entity.PreviewLink, error)

PreviewLinkOf - see entity.PreviewLinkRepository.PreviewLinkOf.

func (r *PreviewLinkRepository) ReplacePreviewLink(ctx context.Context, link entity.PreviewLink, tokenHash string) error

ReplacePreviewLink - see entity.PreviewLinkRepository.ReplacePreviewLink.

type RedirectRepository

type RedirectRepository struct {
	// contains filtered or unexported fields
}

RedirectRepository implements entity.RedirectRepository.

func NewRedirectRepository

func NewRedirectRepository(db *sql.DB) *RedirectRepository

NewRedirectRepository creates a new RedirectRepository.

func (*RedirectRepository) Create

Create inserts a new redirect.

func (*RedirectRepository) Delete

func (r *RedirectRepository) Delete(ctx context.Context, id int) error

Delete removes a redirect by ID.

func (*RedirectRepository) DeleteByFromPath

func (r *RedirectRepository) DeleteByFromPath(ctx context.Context, fromPath string) error

DeleteByFromPath removes a redirect by from_path.

func (*RedirectRepository) List

List returns all redirects ordered by from_path.

func (*RedirectRepository) Search

func (r *RedirectRepository) Search(ctx context.Context, q string, offset, limit int) ([]entity.Redirect, int, error)

Search returns a page of the redirects whose from or to path contains q (letter case aside; "" - all), ordered by from_path, and their count.

type RoleRepository

type RoleRepository struct {
	// contains filtered or unexported fields
}

RoleRepository is the ent-backed entity.RoleRepository.

func NewRoleRepository

func NewRoleRepository(client *generated.RoleClient) *RoleRepository

NewRoleRepository - the role repository on client.

func (RoleRepository) ByID

func (r RoleRepository) ByID(ctx context.Context, id int) (*entity.Role, error)

ByID - the role with id; ErrEntityNotFound if there is none.

func (RoleRepository) ByName

func (r RoleRepository) ByName(ctx context.Context, name string) (*entity.Role, error)

ByName - the role named name; ErrEntityNotFound if there is none.

func (RoleRepository) CountUsers

func (r RoleRepository) CountUsers(ctx context.Context, id int) (int, error)

CountUsers - see entity.RoleRepository.CountUsers.

func (RoleRepository) Create

func (r RoleRepository) Create(ctx context.Context, roleEntity entity.Role) (*entity.Role, error)

Create adds the role and returns it with its ID.

func (RoleRepository) Delete

func (r RoleRepository) Delete(ctx context.Context, id int) error

Delete deletes the role with id.

func (RoleRepository) Find

func (r RoleRepository) Find(ctx context.Context, filter entity.RoleFilter) (*entity.Role, error)

Find - the first role matching filter (by name when it has one); ErrEntityNotFound if there is none.

func (RoleRepository) List

func (r RoleRepository) List(ctx context.Context) (*entity.Roles, error)

List - every role.

func (RoleRepository) Update

func (r RoleRepository) Update(ctx context.Context, roleEntity entity.Role) (*entity.Role, error)

Update saves the role's name, description and permissions over the role with its ID and returns it.

type SEORepository

type SEORepository struct {
	// contains filtered or unexported fields
}

SEORepository - seo_templates and seo_rules (entity.SEOTemplateRepository, entity.SEORuleRepository).

func NewSEORepository

func NewSEORepository(db *sql.DB) *SEORepository

NewSEORepository - the SEO templates and rules repository on db.

func (*SEORepository) CreateSEORule

func (r *SEORepository) CreateSEORule(ctx context.Context, rule entity.SEORuleDef) (*entity.SEORuleDef, error)

CreateSEORule adds the rule and returns it with its ID.

func (*SEORepository) DeleteSEORule

func (r *SEORepository) DeleteSEORule(ctx context.Context, id int) error

DeleteSEORule deletes the rule with id.

func (*SEORepository) SEORuleByID

func (r *SEORepository) SEORuleByID(ctx context.Context, id int) (*entity.SEORuleDef, error)

SEORuleByID - the rule with id; ErrEntityNotFound if there is none.

func (*SEORepository) SEORules

func (r *SEORepository) SEORules(ctx context.Context) (entity.SEORuleDefs, error)

SEORules - see entity.SEORuleRepository.SEORules.

func (*SEORepository) SEOTemplates

func (r *SEORepository) SEOTemplates(ctx context.Context) (entity.SEOTemplates, error)

SEOTemplates - every saved scope's templates, by scope.

func (*SEORepository) SaveSEOTemplate

func (r *SEORepository) SaveSEOTemplate(ctx context.Context, t entity.SEOTemplate) error

SaveSEOTemplate saves a scope's templates, creating the row if it isn't there.

func (*SEORepository) UpdateSEORule

func (r *SEORepository) UpdateSEORule(ctx context.Context, rule entity.SEORuleDef) error

UpdateSEORule saves rule over the rule with its ID.

func (*SEORepository) UpdateSEORuleWeight

func (r *SEORepository) UpdateSEORuleWeight(ctx context.Context, id, weight int) error

UpdateSEORuleWeight sets only the rule's weight (its place in the order).

type SearchConfigRepository

type SearchConfigRepository struct {
	// contains filtered or unexported fields
}

SearchConfigRepository - search_types and search_settings (entity.SearchConfigRepository).

func NewSearchConfigRepository

func NewSearchConfigRepository(db *sql.DB) *SearchConfigRepository

NewSearchConfigRepository - the search settings repository on db.

func (*SearchConfigRepository) SaveSearchSettings

func (r *SearchConfigRepository) SaveSearchSettings(ctx context.Context, s entity.SearchSettings) error

SaveSearchSettings saves s into the search settings row.

func (*SearchConfigRepository) SaveSearchType

func (r *SearchConfigRepository) SaveSearchType(ctx context.Context, t entity.SearchTypeDef) error

SaveSearchType saves a content type's search settings, creating the row if it isn't there.

func (*SearchConfigRepository) SearchSettings

func (r *SearchConfigRepository) SearchSettings(ctx context.Context) (*entity.SearchSettings, error)

SearchSettings - the live search's site-wide settings from their single row.

func (*SearchConfigRepository) SearchTypes

SearchTypes - see entity.SearchConfigRepository.SearchTypes.

func (*SearchConfigRepository) UpdateSearchTypeWeight

func (r *SearchConfigRepository) UpdateSearchTypeWeight(ctx context.Context, nodeType string, weight int) error

UpdateSearchTypeWeight sets only the searched type's weight (its place in the order).

type SearchRepository

type SearchRepository struct {
	// contains filtered or unexported fields
}

SearchRepository runs the live search over the searched node types (entity.SearchTypeDef).

func NewSearchRepository

func NewSearchRepository(client *generated.Client) *SearchRepository

NewSearchRepository creates a new SearchRepository.

func (*SearchRepository) Search

func (r *SearchRepository) Search(ctx context.Context, query string, limit int, types entity.SearchTypeDefs, settings entity.SearchSettings) ([]entity.SearchResult, error)

Search runs the live search for the words of query (searchtext.Query: stemmed in the site's languages, the last one as a beginning), each to be found, in any order, in the search index (search_words):

  1. per type searching fields (searchesFields; in parallel): nodes with every word in the title or one of its fields, up to the type's Limit;
  2. one title search over every searched type (limit*2), every word in the title, adding nodes not found yet;
  3. batch enrichment per type: title/subtitle fields, image field (or its default image, or the placeholder image) in the type's style, badge terms, label;
  4. grouped by type in weight order, inside a type by titleRankOf, then the newest; cut to limit.

func (*SearchRepository) Snippets

func (r *SearchRepository) Snippets(ctx context.Context, query string, results []entity.SearchResult, types entity.SearchTypeDefs) (map[int]entity.SearchSnippet, error)

Snippets - per result its snippet (searchtext.Query.Snippet, the words stemmed in the item's language): from the first of the fields its type searches (searchFields), in their order, whose text has the query's words; a type searching only the title has none.

type SiteInformationRepository

type SiteInformationRepository struct {
	// contains filtered or unexported fields
}

SiteInformationRepository - the site information row. Read on every page, it is kept after the first read until the repository writes it (the site runs one process; app migrate, which writes it too, is followed by a restart).

func NewSiteInformationRepository

func NewSiteInformationRepository(db *sql.DB) *SiteInformationRepository

NewSiteInformationRepository - the site information repository on db.

func (*SiteInformationRepository) Get

Get - the site information; outside a transaction, the one kept since the last write (a copy).

func (*SiteInformationRepository) RenameFrontFeedView

func (r *SiteInformationRepository) RenameFrontFeedView(ctx context.Context, oldName, newName string) error

RenameFrontFeedView - the front page feed's View (FrontFeedView) from display oldName to newName, if it is oldName: the display was renamed.

func (*SiteInformationRepository) SetLanguages

func (r *SiteInformationRepository) SetLanguages(ctx context.Context, languages []entity.SiteLanguage) error

SetLanguages stores the site's languages besides the default one (entity.SiteInformation.Languages).

func (*SiteInformationRepository) SetRobotsExtra

func (r *SiteInformationRepository) SetRobotsExtra(ctx context.Context, rules string) error

SetRobotsExtra stores the site's own robots.txt rules (Access blocking page); Update leaves them as is.

func (*SiteInformationRepository) SetSchemaOrg

SetSchemaOrg stores who runs the site (entity.SiteInformation.SchemaOrg).

func (*SiteInformationRepository) SetTheme

func (r *SiteInformationRepository) SetTheme(ctx context.Context, theme string) error

SetTheme stores the active theme (Appearance page); Update leaves it as is.

func (*SiteInformationRepository) Update

Update saves the site's name, slogan, e-mail, front page feed, timezone, default language, error pages, base URL, logo and icon; the theme, the robots.txt rules, the languages and the schema.org data have their own setters and stay.

type StatisticsSettingsRepository

type StatisticsSettingsRepository struct {
	// contains filtered or unexported fields
}

StatisticsSettingsRepository implements entity.StatisticsSettingsRepository.

func NewStatisticsSettingsRepository

func NewStatisticsSettingsRepository(db *sql.DB) *StatisticsSettingsRepository

NewStatisticsSettingsRepository creates a new StatisticsSettingsRepository.

func (*StatisticsSettingsRepository) Get

Get returns the statistics settings (single row).

func (*StatisticsSettingsRepository) Update

Update saves statistics settings.

type TaxonomyRepository

type TaxonomyRepository struct {
	// contains filtered or unexported fields
}

TaxonomyRepository provides database access to vocabularies and terms.

func NewTaxonomyRepository

func NewTaxonomyRepository(
	client *generated.Client,
) *TaxonomyRepository

NewTaxonomyRepository - the vocabulary and term repository on client.

func (TaxonomyRepository) CountNodesByTermID

func (r TaxonomyRepository) CountNodesByTermID(ctx context.Context, termID int) (int, error)

CountNodesByTermID - see entity.TaxonomyRepository.CountNodesByTermID.

func (TaxonomyRepository) CreateTerm

func (r TaxonomyRepository) CreateTerm(ctx context.Context, vocabularyID int, name, slug string, createdBy int) (*entity.TaxonomyTerm, error)

CreateTerm adds a top-level term to the vocabulary and returns it with its vocabulary.

func (TaxonomyRepository) CreateTermFull

func (r TaxonomyRepository) CreateTermFull(ctx context.Context, vocabularyID int, name, slug, desc string, weight, parentID, createdBy int) (*entity.TaxonomyTerm, error)

CreateTermFull adds a term with all its settings (parentID 0 - a top-level one) and returns it with its vocabulary.

func (TaxonomyRepository) CreateVocabulary

func (r TaxonomyRepository) CreateVocabulary(ctx context.Context, name, slug, termPathPrefix, desc string, publicTermPages bool, weight, createdBy int) (*entity.TaxonomyVocabulary, error)

CreateVocabulary adds a vocabulary and returns it with its ID.

func (TaxonomyRepository) DeleteTerm

func (r TaxonomyRepository) DeleteTerm(ctx context.Context, id int) error

DeleteTerm deletes the term with id; ErrEntityNotFound if there is none.

func (TaxonomyRepository) DeleteVocabulary

func (r TaxonomyRepository) DeleteVocabulary(ctx context.Context, id int) error

DeleteVocabulary deletes the vocabulary with id; ErrEntityNotFound if there is none.

func (TaxonomyRepository) FieldTermIDsForNode

func (r TaxonomyRepository) FieldTermIDsForNode(ctx context.Context, nodeID int) ([]int, error)

FieldTermIDsForNode - see entity.TaxonomyRepository.FieldTermIDsForNode.

func (TaxonomyRepository) NodeTermsByID

func (r TaxonomyRepository) NodeTermsByID(ctx context.Context, nID int) (entity.TaxonomyTerms, error)

NodeTermsByID - the node's terms (each with its vocabulary) from the terms index, in the order they were indexed.

func (TaxonomyRepository) NodeTermsByIDs

func (r TaxonomyRepository) NodeTermsByIDs(ctx context.Context, nodeIDs []int) (map[int]entity.TaxonomyTerms, error)

NodeTermsByIDs is NodeTermsByID batched over many node IDs in one query - for list pages that need per-item terms.

func (TaxonomyRepository) SearchTermsByName

func (r TaxonomyRepository) SearchTermsByName(ctx context.Context, vocabularyID int, query string, limit int) (entity.TaxonomyTerms, error)

SearchTermsByName - at most limit terms of the vocabulary whose name contains query (letter case aside), by weight, then name.

func (TaxonomyRepository) TermByID

func (r TaxonomyRepository) TermByID(ctx context.Context, id int) (*entity.TaxonomyTerm, error)

TermByID - the term with id, with its vocabulary; ErrEntityNotFound if there is none.

func (TaxonomyRepository) TermBySlug

func (r TaxonomyRepository) TermBySlug(ctx context.Context, slug string) (*entity.TaxonomyTerm, error)

TermBySlug - the term with slug, with its vocabulary; ErrEntityNotFound if there is none.

func (TaxonomyRepository) TermNodeCounts

func (r TaxonomyRepository) TermNodeCounts(ctx context.Context, vocabularyID int) (map[int]int, error)

TermNodeCounts - the published content per term that ctx's visitor may view, out of the trash (schema.LiveNodes: the subquery isn't a node query the interceptor sees).

func (TaxonomyRepository) TermsByIDs

func (r TaxonomyRepository) TermsByIDs(ctx context.Context, ids []int) (map[int]entity.TaxonomyTerm, error)

TermsByIDs is TermByID batched over many term IDs in one query - see entity.TaxonomyRepository's doc comment for why.

func (TaxonomyRepository) TermsByVocabularyID

func (r TaxonomyRepository) TermsByVocabularyID(ctx context.Context, vocabularyID int) (entity.TaxonomyTerms, error)

TermsByVocabularyID - every term of the vocabulary, all levels in one flat list, by weight, then name.

func (TaxonomyRepository) UpdateNodeTerms

func (r TaxonomyRepository) UpdateNodeTerms(ctx context.Context, nodeID int, termIDs []int) error

UpdateNodeTerms replaces the node's terms index with termIDs, in one transaction (the caller's when ctx carries one): a failure keeps the old index.

func (TaxonomyRepository) UpdateTerm

func (r TaxonomyRepository) UpdateTerm(ctx context.Context, id int, name, slug, desc string, weight, parentID int) (*entity.TaxonomyTerm, error)

UpdateTerm saves the term's name, slug, description, weight and parent (0 - none) and returns it with its vocabulary; ErrEntityNotFound if there is none.

func (TaxonomyRepository) UpdateTermPageTitle

func (r TaxonomyRepository) UpdateTermPageTitle(ctx context.Context, id int, pageTitle string) error

UpdateTermPageTitle sets only the term's page title.

func (TaxonomyRepository) UpdateTermSortOrder

func (r TaxonomyRepository) UpdateTermSortOrder(ctx context.Context, id int, weight, parentID int) error

UpdateTermSortOrder updates only a term's Weight/ParentID (a bulk reorder), never its Name/Slug/Description.

func (TaxonomyRepository) UpdateVocabulary

func (r TaxonomyRepository) UpdateVocabulary(ctx context.Context, id int, name, slug, termPathPrefix, desc string, publicTermPages bool, weight int) (*entity.TaxonomyVocabulary, error)

UpdateVocabulary saves the vocabulary's name, slug, term path prefix, description, public term pages and weight, and returns it; ErrEntityNotFound if there is none.

func (TaxonomyRepository) UpdateVocabularySortOrder

func (r TaxonomyRepository) UpdateVocabularySortOrder(ctx context.Context, id int, weight int) error

UpdateVocabularySortOrder updates only a vocabulary's Weight (the drag-and-drop reordering), never its Name/Slug/Description.

func (TaxonomyRepository) Vocabularies

Vocabularies - every vocabulary, by weight, then name.

func (TaxonomyRepository) VocabularyByID

func (r TaxonomyRepository) VocabularyByID(ctx context.Context, id int) (*entity.TaxonomyVocabulary, error)

VocabularyByID - the vocabulary with id; ErrEntityNotFound if there is none.

type TextFormatRepository

type TextFormatRepository struct {
	// contains filtered or unexported fields
}

TextFormatRepository is the ent adapter for entity.TextFormatRepository.

func NewTextFormatRepository

func NewTextFormatRepository(client *generated.Client) *TextFormatRepository

NewTextFormatRepository - the text format repository on client.

func (TextFormatRepository) CreateTextFormat

CreateTextFormat adds the text format f and returns it with its ID.

func (TextFormatRepository) DeleteTextFormat

func (r TextFormatRepository) DeleteTextFormat(ctx context.Context, id int) error

DeleteTextFormat doesn't guard against formats still referenced by field_value_text.text_format_id: that content was sanitized at save time and still renders; the edit form just falls back to the field's lowest-weight allowed format.

func (TextFormatRepository) TextFormatByID

func (r TextFormatRepository) TextFormatByID(ctx context.Context, id int) (*entity.TextFormatDef, error)

TextFormatByID - the text format with id; ErrEntityNotFound if there is none.

func (TextFormatRepository) TextFormatByMachineName

func (r TextFormatRepository) TextFormatByMachineName(ctx context.Context, machineName string) (*entity.TextFormatDef, error)

TextFormatByMachineName - the text format named machineName; ErrEntityNotFound if there is none.

func (TextFormatRepository) TextFormats

TextFormats - every text format, by weight.

func (TextFormatRepository) UpdateTextFormat

UpdateTextFormat never touches MachineName: like other machine names, it is an immutable identity string.

type ThemeSettingsRepository

type ThemeSettingsRepository struct {
	// contains filtered or unexported fields
}

ThemeSettingsRepository implements entity.ThemeSettingsRepository.

func NewThemeSettingsRepository

func NewThemeSettingsRepository(db *sql.DB) *ThemeSettingsRepository

NewThemeSettingsRepository creates a new ThemeSettingsRepository.

func (*ThemeSettingsRepository) All

All - every theme's stored values, by theme key.

func (*ThemeSettingsRepository) Save

func (r *ThemeSettingsRepository) Save(ctx context.Context, theme string, values map[string]string) error

Save replaces theme's values, creating its row if it isn't there.

type TwoFactorRepository

type TwoFactorRepository struct {
	// contains filtered or unexported fields
}

TwoFactorRepository - entity.TwoFactorRepository on ent.

func NewTwoFactorRepository

func NewTwoFactorRepository(db *sql.DB) *TwoFactorRepository

NewTwoFactorRepository creates a TwoFactorRepository.

func (*TwoFactorRepository) AcceptStep

func (r *TwoFactorRepository) AcceptStep(ctx context.Context, userID int, step int64) (bool, error)

AcceptStep - see entity.TwoFactorRepository.AcceptStep.

func (*TwoFactorRepository) ByUser

func (r *TwoFactorRepository) ByUser(ctx context.Context, userID int) (*entity.TwoFactor, error)

ByUser - see entity.TwoFactorRepository.ByUser.

func (*TwoFactorRepository) Disable

func (r *TwoFactorRepository) Disable(ctx context.Context, userID int) error

Disable - see entity.TwoFactorRepository.Disable.

func (*TwoFactorRepository) Enable

func (r *TwoFactorRepository) Enable(ctx context.Context, userID int, secret string, step int64, codeHashes []string, at time.Time) error

Enable - see entity.TwoFactorRepository.Enable (the secret sealed).

func (*TwoFactorRepository) EnabledAmong

func (r *TwoFactorRepository) EnabledAmong(ctx context.Context, userIDs []int) (map[int]bool, error)

EnabledAmong - see entity.TwoFactorRepository.EnabledAmong.

func (*TwoFactorRepository) ReplaceRecoveryCodes

func (r *TwoFactorRepository) ReplaceRecoveryCodes(ctx context.Context, userID int, codeHashes []string) error

ReplaceRecoveryCodes - see entity.TwoFactorRepository.ReplaceRecoveryCodes.

func (*TwoFactorRepository) UseRecoveryCode

func (r *TwoFactorRepository) UseRecoveryCode(ctx context.Context, userID int, codeHash string) (bool, error)

UseRecoveryCode - see entity.TwoFactorRepository.UseRecoveryCode.

type UploadSettingsRepository

type UploadSettingsRepository struct {
	// contains filtered or unexported fields
}

UploadSettingsRepository implements entity.UploadSettingsRepository.

func NewUploadSettingsRepository

func NewUploadSettingsRepository(db *sql.DB) *UploadSettingsRepository

NewUploadSettingsRepository - the upload settings repository on db.

func (*UploadSettingsRepository) Get

Get - the upload policy from its single row.

func (*UploadSettingsRepository) Update

Update saves s into the upload policy row.

type UserAuthTokenRepository

type UserAuthTokenRepository struct {
	// contains filtered or unexported fields
}

UserAuthTokenRepository stores hashed one-time login and password-reset tokens.

func NewUserAuthTokenRepository

func NewUserAuthTokenRepository(db *sql.DB) *UserAuthTokenRepository

NewUserAuthTokenRepository - the auth token repository on db.

func (*UserAuthTokenRepository) Consume

func (r *UserAuthTokenRepository) Consume(ctx context.Context, tokenHash, kind string) (userID int, ok bool, err error)

Consume marks the newest matching unused token as used and returns user_id (single-use).

func (*UserAuthTokenRepository) Insert

func (r *UserAuthTokenRepository) Insert(ctx context.Context, userID int, tokenHash, kind string, expiresAt time.Time) error

Insert stores the hash of a token of kind for the user, valid until expiresAt.

func (*UserAuthTokenRepository) InvalidateUserKind

func (r *UserAuthTokenRepository) InvalidateUserKind(ctx context.Context, userID int, kind string) error

InvalidateUserKind removes unused tokens of a kind for a user (e.g. before issuing a new reset).

func (*UserAuthTokenRepository) Pending

func (r *UserAuthTokenRepository) Pending(ctx context.Context, kind string, userIDs []int) (map[int]time.Time, error)

Pending - when each user's newest unused token of kind expires.

func (*UserAuthTokenRepository) Valid

func (r *UserAuthTokenRepository) Valid(ctx context.Context, tokenHash, kind string) (userID int, ok bool, err error)

Valid - the user of an unused, unexpired token (left unused).

type UserContentRepository

type UserContentRepository struct {
	// contains filtered or unexported fields
}

UserContentRepository implements entity.UserContentRepository - cross-table "everything this user owns" queries that don't belong to any single entity's repository.

func NewUserContentRepository

func NewUserContentRepository(db *sql.DB) *UserContentRepository

NewUserContentRepository creates a new UserContentRepository.

func (*UserContentRepository) DeleteUnreferencedFiles

func (r *UserContentRepository) DeleteUnreferencedFiles(ctx context.Context, fileIDs []int) ([]string, error)

DeleteUnreferencedFiles deletes those of the files no file field, default image or module table uses, and returns the URIs no remaining files row shares (safe to remove from disk).

func (*UserContentRepository) FileIDsByCreator

func (r *UserContentRepository) FileIDsByCreator(ctx context.Context, userID int) ([]int, error)

FileIDsByCreator - see entity.UserContentRepository.FileIDsByCreator.

func (*UserContentRepository) ModuleInstalled

func (r *UserContentRepository) ModuleInstalled(ctx context.Context, module string) (bool, error)

ModuleInstalled - whether the module was installed (its tables exist).

func (*UserContentRepository) NodeFileIDs

func (r *UserContentRepository) NodeFileIDs(ctx context.Context, nodeIDs []int) ([]int, error)

NodeFileIDs - the files of the nodes' file fields (their blocks' too: deleted with them) and the ones the modules attach to them.

func (*UserContentRepository) NodeIDs

func (r *UserContentRepository) NodeIDs(ctx context.Context, userID int, limit int) ([]int, error)

NodeIDs - see entity.UserContentRepository.NodeIDs; by ID.

func (*UserContentRepository) NodesWithFile

func (r *UserContentRepository) NodesWithFile(ctx context.Context, fileID int) ([]int, error)

NodesWithFile - the content items whose file fields hold the file: a blocks field's item counts as its node.

func (*UserContentRepository) Summary

Summary - the user's nodes by type (the most first), comments and uploaded files, counted; the modules' content is the caller's.

type UserFieldRepository

type UserFieldRepository struct {
	// contains filtered or unexported fields
}

UserFieldRepository - user_fields / user_field_values.

func NewUserFieldRepository

func NewUserFieldRepository(db *sql.DB) *UserFieldRepository

NewUserFieldRepository - the profile field repository on db.

func (*UserFieldRepository) CreateField

func (r *UserFieldRepository) CreateField(ctx context.Context, f entity.UserFieldDef) (int, error)

CreateField adds the profile field f and returns its ID.

func (*UserFieldRepository) DeleteField

func (r *UserFieldRepository) DeleteField(ctx context.Context, id int) error

DeleteField - see entity.UserFieldRepository.DeleteField.

func (*UserFieldRepository) DeleteUserValues

func (r *UserFieldRepository) DeleteUserValues(ctx context.Context, userID int) error

DeleteUserValues deletes every profile field value of the user.

func (*UserFieldRepository) Fields

Fields - every profile field, by weight, then ID.

func (*UserFieldRepository) SetValues

func (r *UserFieldRepository) SetValues(ctx context.Context, userID int, values map[int]string) error

SetValues saves the user's values: an empty one deletes the row, the rest are updated or created.

func (*UserFieldRepository) UpdateField

UpdateField saves f's label, length limit, weight and whether it is required over the field f.ID (its machine name stays).

func (*UserFieldRepository) Values

func (r *UserFieldRepository) Values(ctx context.Context, userID int) (map[int]string, error)

Values - see entity.UserFieldRepository.Values.

type UserFileUsageRepository

type UserFileUsageRepository struct {
	// contains filtered or unexported fields
}

UserFileUsageRepository implements entity.UserFileUsageRepository. The text scan reads many tables generically, so it stays hand-written SQL (portable; placeholders through rebind).

func NewUserFileUsageRepository

func NewUserFileUsageRepository(db *sql.DB) *UserFileUsageRepository

NewUserFileUsageRepository - the user file usage repository on db.

func (*UserFileUsageRepository) Describe

Describe gives each usage the title of its text's owner and a link.

func (*UserFileUsageRepository) ScanTextsFor

func (r *UserFileUsageRepository) ScanTextsFor(ctx context.Context, path string, fn func(string, int, string)) error

ScanTextsFor - see entity.UserFileUsageRepository.ScanTextsFor; path is relative to the public files' URL.

type UserOAuthIdentityRepository

type UserOAuthIdentityRepository struct {
	// contains filtered or unexported fields
}

UserOAuthIdentityRepository implements entity.UserOAuthIdentityRepository: the provider accounts connected to the users'.

func NewUserOAuthIdentityRepository

func NewUserOAuthIdentityRepository(client *generated.Client) *UserOAuthIdentityRepository

NewUserOAuthIdentityRepository - the connected provider account repository on client.

func (*UserOAuthIdentityRepository) ByUser

ByUser - see entity.UserOAuthIdentityRepository.ByUser; by provider.

func (*UserOAuthIdentityRepository) Create

Create stores the connection identity (an empty e-mail address - none) and returns it with its ID.

func (*UserOAuthIdentityRepository) Delete

func (r *UserOAuthIdentityRepository) Delete(ctx context.Context, userID int, provider string) error

Delete - see entity.UserOAuthIdentityRepository.Delete.

func (*UserOAuthIdentityRepository) FindByProviderUser

func (r *UserOAuthIdentityRepository) FindByProviderUser(ctx context.Context, provider, providerUserID string) (*entity.UserOAuthIdentity, error)

FindByProviderUser - the connection of the provider's account providerUserID; apperrors.ErrNotFound if there is none.

func (*UserOAuthIdentityRepository) FindByUserAndProvider

func (r *UserOAuthIdentityRepository) FindByUserAndProvider(ctx context.Context, userID int, provider string) (*entity.UserOAuthIdentity, error)

FindByUserAndProvider - the user's connection to the provider; apperrors.ErrNotFound if there is none.

type UserRepository

type UserRepository struct {
	// contains filtered or unexported fields
}

UserRepository is the ent-backed entity.UserRepository.

func NewUserRepository

func NewUserRepository(client *generated.UserClient, userFields *UserFieldRepository) *UserRepository

NewUserRepository - the user repository on client; userFields (nil - none) holds the users' profile field values, deleted with a user.

func (UserRepository) BumpSessionVersion

func (r UserRepository) BumpSessionVersion(ctx context.Context, id int) (int, error)

BumpSessionVersion - see entity.UserRepository.BumpSessionVersion.

func (UserRepository) ByID

func (r UserRepository) ByID(ctx context.Context, id int) (*entity.User, error)

ByID - the user id with its role; outside a transaction, once per request (entity.WithUserMemo).

func (UserRepository) ByIDs

func (r UserRepository) ByIDs(ctx context.Context, ids []int) (map[int]entity.User, error)

ByIDs - the users with these ids, by id (a missing one is absent).

func (UserRepository) BySlug

func (r UserRepository) BySlug(ctx context.Context, slug string) (*entity.User, error)

BySlug - the user with slug, with the role; ErrEntityNotFound if there is none.

func (UserRepository) ConfirmEmail

func (r UserRepository) ConfirmEmail(ctx context.Context, userID int) error

ConfirmEmail - see entity.UserRepository.ConfirmEmail.

func (UserRepository) CountWithStatus

func (r UserRepository) CountWithStatus(ctx context.Context, status int) (int, error)

CountWithStatus - see entity.UserRepository.CountWithStatus.

func (UserRepository) Create

func (r UserRepository) Create(ctx context.Context, ct entity.User) (*entity.User, error)

Create adds the user (an empty e-mail address is stored as none) and returns it with its ID.

func (UserRepository) Delete

func (r UserRepository) Delete(ctx context.Context, id int) error

Delete deletes the user with id and the user's profile field values, in one transaction (no key ties the values to the user: a failure between the two would leave them behind).

func (UserRepository) Find

func (r UserRepository) Find(ctx context.Context, filter entity.UserFilter) (*entity.User, error)

Find loads the user with filter.Email (emails are unique, stored in lower case).

func (UserRepository) FindByEmailOrUsername

func (r UserRepository) FindByEmailOrUsername(ctx context.Context, identity string) (*entity.User, error)

FindByEmailOrUsername - see entity.UserRepository.FindByEmailOrUsername; an exact match first, apperrors.ErrNotFound if none matches.

func (UserRepository) FindByUsername

func (r UserRepository) FindByUsername(ctx context.Context, username string) (*entity.User, error)

FindByUsername - the user named username, with the role; ErrEntityNotFound if there is none.

func (UserRepository) List

func (r UserRepository) List(ctx context.Context) (*entity.Users, error)

List - every user, with the role.

func (UserRepository) ListForAdmin

func (r UserRepository) ListForAdmin(ctx context.Context, page int, perPage int, opts entity.AdminPeopleListOpts) (*entity.Users, int, int, error)

ListForAdmin - see entity.UserRepository.ListForAdmin.

func (UserRepository) Search

func (r UserRepository) Search(ctx context.Context, query string, limit int) (*entity.Users, error)

Search - see entity.UserRepository.Search; at most limit (0 - 10).

func (UserRepository) SearchActiveByName

func (r UserRepository) SearchActiveByName(ctx context.Context, query string, roles []int, limit int) (*entity.Users, error)

SearchActiveByName - see entity.UserRepository.SearchActiveByName; by name, at most limit (0 - 10).

func (UserRepository) SessionStateByID

func (r UserRepository) SessionStateByID(ctx context.Context, id int) (int, int, error)

SessionStateByID - see entity.UserRepository.SessionStateByID.

func (UserRepository) TouchAccessedAtIfStale

func (r UserRepository) TouchAccessedAtIfStale(ctx context.Context, userID int, minInterval time.Duration) error

TouchAccessedAtIfStale - see entity.UserRepository.TouchAccessedAtIfStale.

func (UserRepository) Update

func (r UserRepository) Update(ctx context.Context, ct entity.User) (*entity.User, error)

Update saves ct's name, slug, password hash, timezone, signature, status, e-mail address and its confirmation, role and avatar (as AvatarUpdateHint says) over the user ct.ID and returns ct as given.

type ViewRepository

type ViewRepository struct {
	// contains filtered or unexported fields
}

ViewRepository is the ent adapter for entity.ViewRepository: View metadata CRUD here, query execution in view_query.go (filters in view_filters.go, sorting in view_sort.go).

func NewViewRepository

func NewViewRepository(client *generated.Client) *ViewRepository

NewViewRepository - the View repository on client.

func (ViewRepository) AttachmentDisplays

func (r ViewRepository) AttachmentDisplays(ctx context.Context) (entity.ViewDisplayDefs, error)

AttachmentDisplays returns every enabled, non-Default attachment display, ordered by AttachWeight (then id); node pages filter them by content type.

func (ViewRepository) CreateFilter

CreateFilter adds the filter f and returns it with its ID.

func (ViewRepository) CreateSort

CreateSort adds the sort criterion s and returns it with its ID.

func (ViewRepository) CreateView

CreateView adds the display v (an empty URLPath stored as none) and returns it with its ID.

func (ViewRepository) CreateViewContainer

func (r ViewRepository) CreateViewContainer(ctx context.Context, v entity.View) (*entity.View, error)

CreateViewContainer is called only from views.DefaultService.CloneDisplay (see entity.ViewRepository.CreateViewContainer).

func (ViewRepository) CreateViewField

func (r ViewRepository) CreateViewField(ctx context.Context, f entity.ViewFieldDef) (*entity.ViewFieldDef, error)

CreateViewField adds the View field f and returns it with its ID.

func (ViewRepository) DefaultDisplayOfView

func (r ViewRepository) DefaultDisplayOfView(ctx context.Context, viewID int) (*entity.ViewDisplayDef, error)

DefaultDisplayOfView - see entity.ViewRepository.DefaultDisplayOfView.

func (ViewRepository) DeleteFilter

func (r ViewRepository) DeleteFilter(ctx context.Context, id int) error

DeleteFilter deletes the filter with id; ErrEntityNotFound if there is none.

func (ViewRepository) DeleteSort

func (r ViewRepository) DeleteSort(ctx context.Context, id int) error

DeleteSort deletes the sort criterion with id; ErrEntityNotFound if there is none.

func (ViewRepository) DeleteView

func (r ViewRepository) DeleteView(ctx context.Context, id int) error

DeleteView deletes the display with id, its filters, sorts and fields with it; ErrEntityNotFound if there is none.

func (ViewRepository) DeleteViewContainer

func (r ViewRepository) DeleteViewContainer(ctx context.Context, id int) error

DeleteViewContainer deletes the View row by id; ON DELETE CASCADE removes its view_displays rows and, in turn, their filters, sorts and fields.

func (ViewRepository) DeleteViewField

func (r ViewRepository) DeleteViewField(ctx context.Context, id int) error

DeleteViewField deletes the View field with id; ErrEntityNotFound if there is none.

func (ViewRepository) DisplaysOfView

func (r ViewRepository) DisplaysOfView(ctx context.Context, viewID int) (entity.ViewDisplayDefs, error)

DisplaysOfView - see entity.ViewRepository.DisplaysOfView; by creation time.

func (ViewRepository) FieldsByViewID

func (r ViewRepository) FieldsByViewID(ctx context.Context, viewID int) (entity.ViewFieldDefs, error)

FieldsByViewID - the fields of the display viewID, by sort order, then ID.

func (ViewRepository) FilterByID

func (r ViewRepository) FilterByID(ctx context.Context, id int) (*entity.ViewFilterDef, error)

FilterByID - the filter with id; ErrEntityNotFound if there is none.

func (ViewRepository) FiltersByViewID

func (r ViewRepository) FiltersByViewID(ctx context.Context, viewID int) (entity.ViewFilterDefs, error)

FiltersByViewID - the filters of the display viewID, by sort order, then ID.

func (ViewRepository) PageDisplaysWithArgument

func (r ViewRepository) PageDisplaysWithArgument(ctx context.Context) (entity.ViewDisplayDefs, error)

PageDisplaysWithArgument - see entity.ViewRepository.

func (ViewRepository) PublicPageViews

func (r ViewRepository) PublicPageViews(ctx context.Context) (entity.ViewDisplayDefs, error)

PublicPageViews - every non-Default page display across all Views, enabled or not (the callers check Status).

func (ViewRepository) SetPublishedSnapshot

func (r ViewRepository) SetPublishedSnapshot(ctx context.Context, id int, snapshot string, publishedAt time.Time) (*entity.ViewDisplayDef, error)

SetPublishedSnapshot is called only from views.DefaultService.PublishDisplay.

func (ViewRepository) SetViewContainerMachineName

func (r ViewRepository) SetViewContainerMachineName(ctx context.Context, id int, machineName string) (*entity.View, error)

SetViewContainerMachineName is called only from views.DefaultService's create-then-rename sequence right after CreateViewContainer.

func (ViewRepository) SetViewMachineName

func (r ViewRepository) SetViewMachineName(ctx context.Context, id int, machineName string) (*entity.ViewDisplayDef, error)

SetViewMachineName is called only from views.DefaultService's create-then-rename sequence right after CreateView.

func (ViewRepository) SortByID

func (r ViewRepository) SortByID(ctx context.Context, id int) (*entity.ViewSortDef, error)

SortByID - the sort criterion with id; ErrEntityNotFound if there is none.

func (ViewRepository) SortsByViewID

func (r ViewRepository) SortsByViewID(ctx context.Context, viewID int) (entity.ViewSortDefs, error)

SortsByViewID - the sort criteria of the display viewID, by sort order, then ID.

func (ViewRepository) TermDisplays

func (r ViewRepository) TermDisplays(ctx context.Context) (entity.ViewDisplayDefs, error)

TermDisplays returns every enabled, non-Default term display, ordered by AttachWeight (then id); term pages filter them by vocabulary.

func (ViewRepository) UpdateFilter

UpdateFilter saves f over the filter f.ID (its display stays) and returns it; ErrEntityNotFound if there is none.

func (ViewRepository) UpdateSort

UpdateSort never touches FieldStorageID/BuiltinField: a criterion's target is immutable once created; Params are replaced.

func (ViewRepository) UpdateView

UpdateView never touches machine_name (see SetViewMachineName), base_entity (immutable after creation) or published_snapshot/ published_at (see SetPublishedSnapshot), so a caller passing a plain entity.ViewDisplayDef can't accidentally wipe them.

func (ViewRepository) UpdateViewField

func (r ViewRepository) UpdateViewField(ctx context.Context, f entity.ViewFieldDef) (*entity.ViewFieldDef, error)

UpdateViewField never touches FieldStorageID/BuiltinField: a field's target is immutable once created.

func (ViewRepository) UserTabDisplays

func (r ViewRepository) UserTabDisplays(ctx context.Context) (entity.ViewDisplayDefs, error)

UserTabDisplays returns every enabled, non-Default user_tab display, ordered by AttachWeight (then id): the user profile's View tabs.

func (ViewRepository) ViewByID

func (r ViewRepository) ViewByID(ctx context.Context, id int) (*entity.ViewDisplayDef, error)

ViewByID - the display with id; ErrEntityNotFound if there is none.

func (ViewRepository) ViewByMachineName

func (r ViewRepository) ViewByMachineName(ctx context.Context, machineName string) (*entity.ViewDisplayDef, error)

ViewByMachineName - the display named machineName; ErrEntityNotFound if there is none.

func (ViewRepository) ViewByURLPath

func (r ViewRepository) ViewByURLPath(ctx context.Context, urlPath string) (*entity.ViewDisplayDef, error)

ViewByURLPath excludes Default displays as defense in depth: their url_path is a placeholder that must never resolve as a page (see entity.ViewDisplayDef.IsDefault).

func (ViewRepository) ViewByURLPathAny

func (r ViewRepository) ViewByURLPathAny(ctx context.Context, urlPath string) (*entity.ViewDisplayDef, error)

ViewByURLPathAny - see entity.ViewRepository.ViewByURLPathAny.

func (ViewRepository) ViewContainerByID

func (r ViewRepository) ViewContainerByID(ctx context.Context, id int) (*entity.View, error)

ViewContainerByID - see entity.ViewRepository.ViewContainerByID.

func (ViewRepository) ViewFieldByID

func (r ViewRepository) ViewFieldByID(ctx context.Context, id int) (*entity.ViewFieldDef, error)

ViewFieldByID - the View field with id; ErrEntityNotFound if there is none.

func (ViewRepository) Views

Views returns the admin views list: one row per View, not per display. An ungrouped display shows as itself; a grouped View is represented by its Default display, which always exists and so keeps a stable identity as other displays are added or deleted. Sibling displays are reachable via the tab strip in the edit page.

Directories

Path Synopsis
Package viewquery runs Views on the ent schema (entity.ViewQuery): a display's filters, sorts and pager over nodes or comments, its glossary bar and the "similar content" ranking.
Package viewquery runs Views on the ent schema (entity.ViewQuery): a display's filters, sorts and pager over nodes or comments, its glossary bar and the "similar content" ranking.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL