page_models

package
v1.7.0 Latest Latest
Warning

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

Go to latest
Published: May 12, 2025 License: GPL-2.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

View Source
const (
	FieldPK               = "id"
	FieldTitle            = "title"
	FieldPath             = "path"
	FieldDepth            = "depth"
	FieldNumchild         = "numchild"
	FieldUrlPath          = "url_path"
	FieldSlug             = "slug"
	FieldStatusFlags      = "status_flags"
	FieldPageID           = "page_id"
	FieldContentType      = "content_type"
	FieldLatestRevisionID = "latest_revision_id"
	FieldCreatedAt        = "created_at"
	FieldUpdatedAt        = "updated_at"
)

Variables

View Source
var (
	Register   = registry.RegisterForDriver
	GetBackend = registry.BackendForDB
)

Functions

func IsValidField added in v1.7.0

func IsValidField(f string) bool

Types

type DBQuerier

type DBQuerier interface {
	Querier
	DB() *sql.DB
	BeginTx(ctx context.Context, opts *sql.TxOptions) (*sql.Tx, error)
}

type DBTX

type DBTX interface {
	ExecContext(context.Context, string, ...interface{}) (sql.Result, error)
	PrepareContext(context.Context, string) (*sql.Stmt, error)
	QueryContext(context.Context, string, ...interface{}) (*sql.Rows, error)
	QueryRowContext(context.Context, string, ...interface{}) *sql.Row
}

type PageNode

type PageNode struct {
	PK               int64      `json:"id" attrs:"primary;readonly"`
	Title            string     `json:"title"`
	Path             string     `json:"path"`
	Depth            int64      `json:"depth" attrs:"blank"`
	Numchild         int64      `json:"numchild" attrs:"blank"`
	UrlPath          string     `json:"url_path" attrs:"readonly;blank"`
	Slug             string     `json:"slug"`
	StatusFlags      StatusFlag `json:"status_flags" attrs:"null;blank"`
	PageID           int64      `json:"page_id" attrs:""`
	ContentType      string     `json:"content_type" attrs:""`
	LatestRevisionID int64      `json:"latest_revision_id" attrs:""`
	CreatedAt        time.Time  `json:"created_at" attrs:"readonly;label=Created At"`
	UpdatedAt        time.Time  `json:"updated_at" attrs:"readonly;label=Updated At"`

	// ParentNode is the parent node of this node.
	// It will likely be nil and is not fetched by default.
	ParentNode *PageNode `json:"parent_node" attrs:"readonly"`

	// ChildNodes are the child nodes of this node.
	// It will likely be nil and is not fetched by default.
	ChildNodes []*PageNode `json:"child_nodes" attrs:"readonly"`
}

func (*PageNode) FieldDefs

func (n *PageNode) FieldDefs() attrs.Definitions

func (*PageNode) ID

func (n *PageNode) ID() int64

func (*PageNode) IsRoot

func (n *PageNode) IsRoot() bool

func (*PageNode) Reference

func (n *PageNode) Reference() *PageNode

func (*PageNode) SetUrlPath added in v1.7.0

func (n *PageNode) SetUrlPath(parent *PageNode) (newPath, oldPath string)

type Querier

type Querier interface {
	Close() error
	WithTx(tx *sql.Tx) Querier
	AllNodes(ctx context.Context, statusFlags StatusFlag, offset int32, limit int32, orderings ...string) ([]PageNode, error)
	CountNodes(ctx context.Context, statusFlags StatusFlag) (int64, error)
	CountNodesByTypeHash(ctx context.Context, contentType string) (int64, error)
	CountRootNodes(ctx context.Context, statusFlags StatusFlag) (int64, error)
	DecrementNumChild(ctx context.Context, id int64) (PageNode, error)
	DeleteDescendants(ctx context.Context, path string, depth int64) error
	DeleteNode(ctx context.Context, id int64) error
	DeleteNodes(ctx context.Context, id []int64) error
	GetChildNodes(ctx context.Context, path string, depth int64, statusFlags StatusFlag, offset int32, limit int32) ([]PageNode, error)
	GetDescendants(ctx context.Context, path string, depth int64, statusFlags StatusFlag, offset int32, limit int32) ([]PageNode, error)
	GetNodeByID(ctx context.Context, id int64) (PageNode, error)
	GetNodeByPath(ctx context.Context, path string) (PageNode, error)
	GetNodeBySlug(ctx context.Context, slug string, depth int64, path string) (PageNode, error)
	GetNodesByDepth(ctx context.Context, depth int64, statusFlags StatusFlag, offset int32, limit int32) ([]PageNode, error)
	GetNodesByIDs(ctx context.Context, id []int64) ([]PageNode, error)
	GetNodesByPageIDs(ctx context.Context, pageID []int64) ([]PageNode, error)
	GetNodesByTypeHash(ctx context.Context, contentType string, offset int32, limit int32) ([]PageNode, error)
	GetNodesByTypeHashes(ctx context.Context, contentType []string, offset int32, limit int32) ([]PageNode, error)
	GetNodesForPaths(ctx context.Context, path []string) ([]PageNode, error)
	IncrementNumChild(ctx context.Context, id int64) (PageNode, error)
	InsertNode(ctx context.Context, title string, path string, depth int64, numchild int64, urlPath string, slug string, statusFlags int64, pageID int64, contentType string, latestRevisionID int64) (int64, error)
	UpdateNode(ctx context.Context, title string, path string, depth int64, numchild int64, urlPath string, slug string, statusFlags int64, pageID int64, contentType string, latestRevisionID int64, iD int64) error
	UpdateNodes(ctx context.Context, nodes []*PageNode) error
	UpdateNodePathAndDepth(ctx context.Context, path string, depth int64, iD int64) error
	UpdateNodeStatusFlags(ctx context.Context, statusFlags int64, iD int64) error
	UpdateDescendantPaths(ctx context.Context, oldUrlPath, newUrlPath, pageNodePath string, id int64) error
}

type StatusFlag

type StatusFlag int64
const (
	// StatusFlagPublished is the status flag for published pages.
	StatusFlagPublished StatusFlag = 1 << iota

	// StatusFlagHidden is the status flag for hidden pages.
	StatusFlagHidden

	// StatusFlagDeleted is the status flag for deleted pages.
	StatusFlagDeleted

	// StatusflagNone is the status flag for no status.
	//
	// It is mainly used in queries to ignore the status flag in where clauses.
	StatusFlagNone StatusFlag = 0
)

func (StatusFlag) Is

func (f StatusFlag) Is(flag StatusFlag) bool

Jump to

Keyboard shortcuts

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