Documentation
¶
Index ¶
- Variables
- func ItemRef(c *ent.Node) (datagraph.Item, error)
- func MapNode(isRoot bool, ps *PropertySchemaTable) func(c *ent.Node) (*Node, error)
- func RoleHydrationTargetsFromNode(root *ent.Node) []*ent.Account
- type ExistingPropertyMutation
- type ExistingPropertyMutations
- type Mark
- type Node
- func (c *Node) GetAssets() []*asset.Asset
- func (c *Node) GetAuthor() xid.ID
- func (c *Node) GetContent() datagraph.Content
- func (c *Node) GetCreated() time.Time
- func (c *Node) GetDesc() string
- func (c *Node) GetID() xid.ID
- func (c *Node) GetKind() datagraph.Kind
- func (c *Node) GetName() string
- func (c *Node) GetProps() map[string]any
- func (*Node) GetResourceName() string
- func (c *Node) GetSlug() string
- func (c *Node) GetTags() []string
- func (c *Node) GetUpdated() time.Time
- type NodeID
- type NodeSlug
- type Properties
- type Property
- type PropertyMutation
- type PropertyMutationList
- type PropertySchema
- type PropertySchemaField
- type PropertySchemaFields
- type PropertySchemaMutation
- type PropertySchemaQueryRow
- type PropertySchemaQueryRows
- type PropertySchemaTable
- type PropertyTable
- type PropertyType
- func (r PropertyType) Format(f fmt.State, verb rune)
- func (r PropertyType) MarshalText() ([]byte, error)
- func (r *PropertyType) Scan(__iNpUt__ any) error
- func (r PropertyType) String() string
- func (r *PropertyType) UnmarshalText(__iNpUt__ []byte) error
- func (r PropertyType) Value() (driver.Value, error)
- type QueryKey
Constants ¶
This section is empty.
Variables ¶
var ( PropertyTypeEnumText = PropertyType{propertyTypeEnumText} PropertyTypeEnumNumber = PropertyType{propertyTypeEnumNumber} PropertyTypeEnumTimestamp = PropertyType{propertyTypeEnumTimestamp} PropertyTypeEnumBoolean = PropertyType{propertyTypeEnumBoolean} )
Functions ¶
Types ¶
type ExistingPropertyMutation ¶
type ExistingPropertyMutation struct {
PropertySchemaField
IsSchemaChanged bool
Value string
}
type ExistingPropertyMutations ¶
type ExistingPropertyMutations []*ExistingPropertyMutation
type Node ¶
type Node struct {
Mark Mark
CreatedAt time.Time
UpdatedAt time.Time
IndexedAt opt.Optional[time.Time]
Name string
Assets []*asset.Asset
WebLink opt.Optional[link_ref.LinkRef]
Content opt.Optional[datagraph.Content]
Description opt.Optional[string]
PrimaryImage opt.Optional[asset.Asset]
Owner profile.Ref
Parent opt.Optional[Node]
Properties opt.Optional[PropertyTable]
ChildProperties opt.Optional[PropertySchema]
HideChildTree bool
Tags tag_ref.Tags
Collections collection_item_status.Status // NOTE: Not done yet
Visibility visibility.Visibility
SortKey lexorank.Key
RelevanceScore opt.Optional[float64]
Metadata map[string]any
Nodes []*Node
}
func (*Node) GetContent ¶
func (*Node) GetCreated ¶
func (*Node) GetResourceName ¶
func (*Node) GetUpdated ¶
type Properties ¶
type Properties []*Property
type PropertyMutation ¶
type PropertyMutation struct {
// ID is optional, when set the mutation is modifying an existing field and
// when not set, the mutation assumes it's a new field.
ID opt.Optional[xid.ID]
Name string
Value string
Type opt.Optional[PropertyType]
Sort opt.Optional[string]
}
Property mutations are used to update properties on a node.
type PropertyMutationList ¶
type PropertyMutationList []*PropertyMutation
type PropertySchema ¶
type PropertySchema struct {
ID xid.ID
Fields PropertySchemaFields
}
func (PropertySchema) FieldIDs ¶
func (p PropertySchema) FieldIDs() []xid.ID
func (PropertySchema) GetField ¶
func (p PropertySchema) GetField(id xid.ID) (*PropertySchemaField, bool)
func (PropertySchema) Split ¶
func (p PropertySchema) Split(mutation PropertyMutationList) (*PropertySchemaMutation, error)
Split takes a mutation (a list of properties to update) and splits it into two lists, one for properties that need to be added to the schema and current schema fields which can be processed as simple property update operations. We also need to get the actual field ID for each existing property.
type PropertySchemaField ¶
type PropertySchemaField struct {
ID xid.ID
Name string
Type PropertyType
Sort string
}
func MapPropertyFieldSchema ¶
func MapPropertyFieldSchema(in PropertySchemaQueryRow) PropertySchemaField
type PropertySchemaFields ¶
type PropertySchemaFields []*PropertySchemaField
type PropertySchemaMutation ¶
type PropertySchemaMutation struct {
NewProps PropertyMutationList
ExistingProps ExistingPropertyMutations
RemovedProps ExistingPropertyMutations
}
type PropertySchemaQueryRow ¶
type PropertySchemaQueryRow struct {
SchemaID xid.ID `db:"schema_id"`
FieldID xid.ID `db:"field_id"`
Name string `db:"name"`
Type PropertyType `db:"type"`
Sort string `db:"sort"`
Source string `db:"source"`
}
PropertySchemaQueryRow is a row from the property schema query which pulls all the property schemas for both sibling and child properties of a node.
type PropertySchemaQueryRows ¶
type PropertySchemaQueryRows []PropertySchemaQueryRow
func (PropertySchemaQueryRows) Map ¶
func (r PropertySchemaQueryRows) Map() *PropertySchemaTable
Map harmonises the splits the raw rows into sibling and child schemas.
type PropertySchemaTable ¶
type PropertySchemaTable struct {
// contains filtered or unexported fields
}
func (*PropertySchemaTable) BuildPropertyTable ¶
func (r *PropertySchemaTable) BuildPropertyTable(in []*ent.Property, isRoot bool) *PropertyTable
BuildPropertyTable yields the properties that are set for the node and also properties that don't have values by merging in the unused property schemas.
func (PropertySchemaTable) ChildSchemas ¶
func (r PropertySchemaTable) ChildSchemas() *PropertySchema
type PropertyTable ¶
type PropertyTable struct {
Schema PropertySchema
Properties Properties
}
type PropertyType ¶
type PropertyType struct {
// contains filtered or unexported fields
}
func NewPropertyType ¶
func NewPropertyType(__iNpUt__ string) (PropertyType, error)
func (PropertyType) MarshalText ¶
func (r PropertyType) MarshalText() ([]byte, error)
func (*PropertyType) Scan ¶
func (r *PropertyType) Scan(__iNpUt__ any) error
func (PropertyType) String ¶
func (r PropertyType) String() string
func (*PropertyType) UnmarshalText ¶
func (r *PropertyType) UnmarshalText(__iNpUt__ []byte) error