trilium_alchemy.core.attribute

Class index

Canonical

BaseAttribute

Encapsulates an attribute, a key-value record attached to a note.

Label

Encapsulates a label.

Relation

Encapsulates a relation.

Symbols

class trilium_alchemy.core.attribute.BaseAttribute(name: str, inheritable: bool = False, session: Session | None = None, _attribute_id: str | None = None, _owning_note: Note | None = None, _model_backing: AttributeModel | None = None)

Bases:

trilium_alchemy.core.entity.entity.OrderedEntity
abc.ABC

Aliases:

trilium_alchemy.BaseAttribute
trilium_alchemy.core.BaseAttribute

Encapsulates an attribute, a key-value record attached to a note.

Can’t be instantiated directly; use Label or Relation concrete classes.

Once instantiated, the attribute needs to be added to a Note. See the documentation of Note for details.

Note

Value is accessed differently depending on the concrete class:

property attribute_id: str | None

Getter for attributeId, or None if not created yet.

property name: str

Getter for attribute name.

property inheritable: bool

Getter/setter for whether this attribute is inherited to children and by template/inherit relations.

property utc_date_modified: str

UTC modified datetime, e.g. 2021-12-31 19:18:11.939Z.

property note: Note | None

Getter for note which owns this attribute, or None if it hasn’t been bound to a note yet.

property position: int

Getter for position of this attribute.

Note

This is maintained automatically based on the order of this attribute in its note’s Note.attributes list.

property state: State

Inherited from: trilium_alchemy.core.entity.BaseEntity

Current state.

property session: Session

Inherited from: trilium_alchemy.core.entity.BaseEntity

Session to which this entity belongs.

property str_short: str

Inherited from: trilium_alchemy.core.entity.BaseEntity

Get a short description of this entity.

property str_summary: str

Inherited from: trilium_alchemy.core.entity.BaseEntity

Get a summary of this entity, including its current state and model values.

flush()

Inherited from: trilium_alchemy.core.entity.BaseEntity

Commit changes to Trilium for this entity and its dependencies.

invalidate()

Inherited from: trilium_alchemy.core.entity.BaseEntity

Discard cached contents and user-provided data for this object. Upon next access, data will be fetched from Trilium.

delete()

Inherited from: trilium_alchemy.core.entity.BaseEntity

Mark this entity for pending delete.

refresh()

Inherited from: trilium_alchemy.core.entity.BaseEntity

Update value from Trilium, discarding any local changes.

class trilium_alchemy.core.attribute.Label(name: str, value: str = '', inheritable: bool = False, session: Session | None = None, **kwargs)
Parameters:
name: str

Label name

value: str = ''

Label value, or empty string

inheritable: bool = False

Whether attribute is inherited to children

session: Session | None = None

Session, or None to use default

kwargs

Internal only

Bases:

trilium_alchemy.core.attribute.BaseAttribute

Aliases:

trilium_alchemy.Label
trilium_alchemy.core.Label

Encapsulates a label.

Once instantiated, the label needs to be added to a Note; see Attributes for details.

property value: str

Getter/setter for label value, which may be an empty string.

property attribute_id: str | None

Inherited from: trilium_alchemy.core.attribute.BaseAttribute

Getter for attributeId, or None if not created yet.

property name: str

Inherited from: trilium_alchemy.core.attribute.BaseAttribute

Getter for attribute name.

property inheritable: bool

Inherited from: trilium_alchemy.core.attribute.BaseAttribute

Getter/setter for whether this attribute is inherited to children and by template/inherit relations.

property utc_date_modified: str

Inherited from: trilium_alchemy.core.attribute.BaseAttribute

UTC modified datetime, e.g. 2021-12-31 19:18:11.939Z.

property note: Note | None

Inherited from: trilium_alchemy.core.attribute.BaseAttribute

Getter for note which owns this attribute, or None if it hasn’t been bound to a note yet.

property position: int

Inherited from: trilium_alchemy.core.attribute.BaseAttribute

Getter for position of this attribute.

Note

This is maintained automatically based on the order of this attribute in its note’s Note.attributes list.

property state: State

Inherited from: trilium_alchemy.core.entity.BaseEntity

Current state.

property session: Session

Inherited from: trilium_alchemy.core.entity.BaseEntity

Session to which this entity belongs.

property str_short: str

Inherited from: trilium_alchemy.core.entity.BaseEntity

Get a short description of this entity.

property str_summary: str

Inherited from: trilium_alchemy.core.entity.BaseEntity

Get a summary of this entity, including its current state and model values.

flush()

Inherited from: trilium_alchemy.core.entity.BaseEntity

Commit changes to Trilium for this entity and its dependencies.

invalidate()

Inherited from: trilium_alchemy.core.entity.BaseEntity

Discard cached contents and user-provided data for this object. Upon next access, data will be fetched from Trilium.

delete()

Inherited from: trilium_alchemy.core.entity.BaseEntity

Mark this entity for pending delete.

refresh()

Inherited from: trilium_alchemy.core.entity.BaseEntity

Update value from Trilium, discarding any local changes.

class trilium_alchemy.core.attribute.Relation(name: str, target: Note | None = None, inheritable: bool = False, session: Session | None = None, **kwargs)
Parameters:
name: str

Relation name

target: Note | None = None

Target note

inheritable: bool = False

Whether attribute is inherited to children

session: Session | None = None

Session, or None to use default

kwargs

Internal only

Bases:

trilium_alchemy.core.attribute.BaseAttribute

Aliases:

trilium_alchemy.Relation
trilium_alchemy.core.Relation

Encapsulates a relation.

Once instantiated, the relation needs to be added to a Note; see Attributes for details.

property target: Note

Getter/setter for target note, with getter validating that the target has already been assigned.

property target_raw: Note | None

Getter for target note, or None if not yet assigned.

property attribute_id: str | None

Inherited from: trilium_alchemy.core.attribute.BaseAttribute

Getter for attributeId, or None if not created yet.

property name: str

Inherited from: trilium_alchemy.core.attribute.BaseAttribute

Getter for attribute name.

property inheritable: bool

Inherited from: trilium_alchemy.core.attribute.BaseAttribute

Getter/setter for whether this attribute is inherited to children and by template/inherit relations.

property utc_date_modified: str

Inherited from: trilium_alchemy.core.attribute.BaseAttribute

UTC modified datetime, e.g. 2021-12-31 19:18:11.939Z.

property note: Note | None

Inherited from: trilium_alchemy.core.attribute.BaseAttribute

Getter for note which owns this attribute, or None if it hasn’t been bound to a note yet.

property position: int

Inherited from: trilium_alchemy.core.attribute.BaseAttribute

Getter for position of this attribute.

Note

This is maintained automatically based on the order of this attribute in its note’s Note.attributes list.

property state: State

Inherited from: trilium_alchemy.core.entity.BaseEntity

Current state.

property session: Session

Inherited from: trilium_alchemy.core.entity.BaseEntity

Session to which this entity belongs.

property str_short: str

Inherited from: trilium_alchemy.core.entity.BaseEntity

Get a short description of this entity.

property str_summary: str

Inherited from: trilium_alchemy.core.entity.BaseEntity

Get a summary of this entity, including its current state and model values.

flush()

Inherited from: trilium_alchemy.core.entity.BaseEntity

Commit changes to Trilium for this entity and its dependencies.

invalidate()

Inherited from: trilium_alchemy.core.entity.BaseEntity

Discard cached contents and user-provided data for this object. Upon next access, data will be fetched from Trilium.

delete()

Inherited from: trilium_alchemy.core.entity.BaseEntity

Mark this entity for pending delete.

refresh()

Inherited from: trilium_alchemy.core.entity.BaseEntity

Update value from Trilium, discarding any local changes.