Trilium's main entity, which can represent text note, image, code note, file attachment etc.

Hierarchy (View Summary)

Constructors

Properties

Accessors

Methods

__validateTypeName _getContent _setContent addAttribute addLabel addRelation areAllNotePathsArchived beforeSaving cloneTo convertToParentAttachment decrypt deleteNote eraseExcessRevisionSnapshots generateHash getAllNotePaths getAncestorNoteIds getAncestors getAttachmentById getAttachmentByTitle getAttachments getAttachmentsByRole getAttribute getAttributeCaseInsensitive getAttributes getAttributeValue getBestNotePath getBestNotePathString getBranches getChildBranches getChildNotes getContent getDescendantNoteIds getDistanceToAncestor getFileName getFlatText getInheritingNotes getJsonContent getJsonContentSafely getLabel getLabelDefinitions getLabels getLabelValue getLabelValues getOwnedAttribute getOwnedAttributes getOwnedAttributeValue getOwnedLabel getOwnedLabels getOwnedLabelValue getOwnedLabelValues getOwnedRelation getOwnedRelations getOwnedRelationValue getParentBranches getParentNotes getPojo getPojoToSave getRelation getRelationDefinitions getRelations getRelationTarget getRelationValue getRevisions getScriptEnv getSearchResultNotes getSortedNotePathRecords getStrongParentBranches getSubtree getSubtreeNoteIds getSubtreeNotesIncludingTemplated getTargetRelations getTitleOrProtected getUtcDateChanged hasAncestor hasAttribute hasChildren hasInheritableArchivedLabel hasLabel hasOwnedAttribute hasOwnedLabel hasOwnedRelation hasRelation hasStringContent init invalidateSubTree invalidateThisCache isContentAvailable isDescendantOfNote isEligibleForConversionToAttachment isHiddenCompletely isHtml isImage isInherited isInHiddenSubtree isJavaScript isJson isLabelTruthy isLaunchBarConfig isOptions isRoot isStringNote markAsDeleted markAsDeletedSimple putEntityChange removeAttribute removeLabel removeRelation save saveAttachment saveRevision searchNoteInSubtree searchNotesInSubtree setAttribute setContent setJsonContent setLabel setRelation sortChildren sortParents toggleAttribute toggleLabel toggleRelation update updateFromRow

Constructors

Properties

__flatTextCache: null | string
blobId?: string
children: default[]
contentAndAttachmentsAndRevisionsSize: null | number

size of the note content, attachment contents and revision contents in bytes

contentAndAttachmentsSize: null | number

size of the note content, attachment contents in bytes

contentSize: null | number

size of the content in bytes

dateCreated?: string
dateModified?: string
isBeingDeleted: boolean

set during the deletion operation, before it is completed (removed from becca completely).

isDecrypted: boolean
isProtected?: boolean
isSynced?: boolean
mime: string
noteId: string
ownedAttributes: default[]
parentBranches: default[]
parents: default[]
revisionCount: null | number

number of note revisions for this note

targetRelations: default[]
title: string
type:
    | "search"
    | "file"
    | "text"
    | "code"
    | "relationMap"
    | "render"
    | "book"
    | "mermaid"
    | "canvas"
    | "image"
    | "noteMap"
    | "launcher"
    | "doc"
    | "contentWidget"
    | "webView"
    | "mindMap"
utcDateCreated: string
utcDateModified?: string

Accessors

Methods

  • Parameters

    • Optionaltype: null | string
    • Optionalname: null | string

    Returns void

  • Adds a new attribute to this note. The attribute is saved and returned. See addLabel, addRelation for more specific methods.

    Parameters

    • type: AttributeType

      attribute type (label / relation)

    • name: string

      name of the attribute, not including the leading ~/#

    • value: string = ""

      value of the attribute - text for labels, target note ID for relations; optional.

    • isInheritable: boolean = false
    • position: null | number = null

    Returns default

  • Adds a new label to this note. The label attribute is saved and returned.

    Parameters

    • name: string

      name of the label, not including the leading #

    • value: string = ""

      text value of the label; optional

    • isInheritable: boolean = false

    Returns default

  • Adds a new relation to this note. The relation attribute is saved and returned.

    Parameters

    • name: string

      name of the relation, not including the leading ~

    • targetNoteId: string
    • isInheritable: boolean = false

    Returns default

  • Some notes are eligible for conversion into an attachment of its parent, note must have these properties:

    • it has exactly one target relation
    • it has a relation from its parent note
    • it has no children
    • it has no clones
    • the parent is of type text
    • both notes are either unprotected or user is in protected session

    Currently, works only for image notes.

    In the future, this functionality might get more generic and some of the requirements relaxed.

    Parameters

    • opts: ConvertOpts = ...

    Returns null | default

    null if note is not eligible for conversion

  • (Soft) delete a note and all its descendants.

    Parameters

    • deleteId: null | string = null

      optional delete identified

    • taskContext: null | TaskContext = null

    Returns void

  • Gives all possible note paths leading to this note. Paths containing search note are ignored (could form cycles)

    Returns string[][]

    array of notePaths (each represented by array of noteIds constituting the particular note path)

  • Parameters

    • type: string

      attribute type (label, relation, etc.)

    • name: string

      attribute name

    Returns null | default

    attribute of the given type and name. If there are more such attributes, first is returned. Returns null if there's no such attribute belonging to this note.

  • Parameters

    • type: string
    • name: string
    • Optionalvalue: null | string

    Returns undefined | default

  • Beware that the method must not create a copy of the array, but actually returns its internal array (for performance reasons)

    Parameters

    • Optionaltype: string

      (optional) attribute type to filter

    • Optionalname: string

      (optional) attribute name to filter

    Returns default[]

    all note's attributes, including inherited ones

  • Parameters

    • type: string

      attribute type (label, relation, etc.)

    • name: string

      attribute name

    Returns null | string

    attribute value of given type and name or null if no such attribute exists.

  • Returns a note path considered to be the "best"

    Parameters

    • hoistedNoteId: string = 'root'

    Returns string[]

    array of noteIds constituting the particular note path

  • Returns a note path considered to be the "best"

    Parameters

    • hoistedNoteId: string = 'root'

    Returns string

    serialized note path (e.g. 'root/a1h315/js725h')

  • Note content has quite special handling - it's not a separate entity, but a lazily loaded part of Note entity with its own sync. Reasons behind this hybrid design has been:

    • content can be quite large, and it's not necessary to load it / fill memory for any note access even if we don't need a content, especially for bulk operations like search
    • changes in the note metadata or title should not trigger note content sync (so we keep separate utcDateModified and entity changes records)
    • but to the user note content and title changes are one and the same - single dateModified (so all changes must go through Note and content is not a separate entity)

    Returns string | Buffer<ArrayBufferLike>

  • This is used for:

    • fast searching
    • note similarity evaluation

    Returns string

    • returns flattened textual representation of note, prefixes and attributes
  • Returns default[]

    returns only notes which are templated, does not include their subtrees in effect returns notes which are influenced by note's non-inheritable attributes

  • Returns any

    valid object or null if the content cannot be parsed as JSON

  • Parameters

    • Optionalname: string

      label name to filter

    Returns default[]

    all note's labels (attributes with type label), including inherited ones

  • Parameters

    • name: string

      label name

    Returns null | string

    label value if label exists, null otherwise

  • Parameters

    • name: string

      label name to filter

    Returns string[]

    all note's label values, including inherited ones

  • Parameters

    • type: string
    • name: string
    • value: null | string = null

    Returns null | default

    attribute belonging to this specific note (excludes inherited attributes)

    This method can be significantly faster than the getAttribute()

  • Beware that the method must not create a copy of the array, but actually returns its internal array (for performance reasons)

    Parameters

    • type: null | string = null

      (optional) attribute type to filter

    • name: null | string = null

      (optional) attribute name to filter

    • value: null | string = null

      (optional) attribute value to filter

    Returns default[]

    note's "owned" attributes - excluding inherited ones

  • Parameters

    • type: string

      attribute type (label, relation, etc.)

    • name: string

      attribute name

    Returns null | string

    attribute value of given type and name or null if no such attribute exists.

  • Parameters

    • name: string

      label name to filter

    Returns default[]

    all note's labels (attributes with type label), excluding inherited ones

  • Parameters

    • name: string

      label name

    Returns null | string

    label value if label exists, null otherwise

  • Parameters

    • name: string

      label name to filter

    Returns string[]

    all note's label values, excluding inherited ones

  • Parameters

    • Optionalname: null | string

      relation name to filter

    Returns default[]

    all note's relations (attributes with type relation), excluding inherited ones

  • Parameters

    • name: string

      relation name

    Returns null | string

    relation value if relation exists, null otherwise

  • Parameters

    • Optionalname: string

      relation name to filter

    Returns default[]

    all note's relations (attributes with type relation), including inherited ones

  • Parameters

    • name: string

      relation name

    Returns null | string

    relation value if relation exists, null otherwise

  • Returns null | "frontend" | "backend"

    JS script environment - either "frontend" or "backend"

  • Parameters

    • hoistedNoteId: string = 'root'

    Returns NotePathRecord[]

  • Parameters

    • __namedParameters: { includeArchived?: boolean; includeHidden?: boolean; resolveSearch?: boolean } = {}

    Returns { notes: default[]; relationships: Relationship[] }

  • Parameters

    • __namedParameters: { includeArchived?: boolean; includeHidden?: boolean; resolveSearch?: boolean } = {}

    Returns string[]

    includes the subtree root note as well

  • Parameters

    • type: string
    • name: string
    • value: null | string = null

    Returns boolean

  • Parameters

    • name: string

      label name

    • Optionalvalue: string

      label value

    Returns boolean

    true if label exists (including inherited)

  • Parameters

    • type: string
    • name: string

      attribute name

    • Optionalvalue: string

      attribute value

    Returns boolean

    true if note has an attribute with given type and name (excluding inherited)

  • Parameters

    • name: string

      label name

    • Optionalvalue: string

      label value

    Returns boolean

    true if label exists (excluding inherited)

  • Parameters

    • name: string

      relation name

    • Optionalvalue: string

      relation value

    Returns boolean

    true if relation exists (excluding inherited)

  • Parameters

    • name: string

      relation name

    • Optionalvalue: string

      relation value

    Returns boolean

    true if relation exists (including inherited)

  • Parameters

    • ancestorNoteId: string

    Returns boolean

    true if ancestorNoteId occurs in at least one of the note's paths

  • Parameters

    • opts: ConvertOpts = ...

    Returns boolean

  • Returns boolean

    boolean - true if there's no non-hidden path, note is not cloned to the visible tree

  • Parameters

    • name: string

      label name

    Returns boolean

    true if label exists (including inherited) and does not have "false" value.

  • Returns boolean

    true if this note is the root of the note tree. Root note has "root" noteId

  • Mark the entity as (soft) deleted. It will be completely erased later.

    This is a low-level method, for notes and branches use note.deleteNote() and 'branch.deleteBranch()` instead.

    Parameters

    • deleteId: null | string = null

    Returns void

  • Removes given attribute name-value pair if it exists.

    Parameters

    • type: string

      attribute type (label, relation, etc.)

    • name: string

      attribute name

    • Optionalvalue: string

      attribute value (optional)

    Returns void

  • Remove label name-value pair, if it exists.

    Parameters

    • name: string

      label name

    • Optionalvalue: string

      label value

    Returns void

  • Remove the relation name-value pair, if it exists.

    Parameters

    • name: string

      relation name

    • Optionalvalue: string

      relation value (noteId)

    Returns void

  • Update's given attribute's value or creates it if it doesn't exist

    Parameters

    • type: AttributeType

      attribute type (label, relation, etc.)

    • name: string

      attribute name

    • Optionalvalue: string

      attribute value (optional)

    Returns void

  • Parameters

    • content: string | Buffer<ArrayBufferLike>
    • opts: ContentOpts = {}

    Returns void

  • Update's given label's value or creates it if it doesn't exist

    Parameters

    • name: string

      label name

    • Optionalvalue: string

      label value

    Returns void

  • Update's given relation's value or creates it if it doesn't exist

    Parameters

    • name: string

      relation name

    • Optionalvalue: string

      relation value (noteId)

    Returns void

  • Based on enabled, the attribute is either set or removed.

    Parameters

    • type: AttributeType

      attribute type ('relation', 'label' etc.)

    • enabled: boolean

      toggle On or Off

    • name: string

      attribute name

    • Optionalvalue: string

      attribute value (optional)

    Returns void

  • Based on enabled, label is either set or removed.

    Parameters

    • enabled: boolean

      toggle On or Off

    • name: string

      label name

    • Optionalvalue: string

      label value (optional)

    Returns void

  • Based on enabled, relation is either set or removed.

    Parameters

    • enabled: boolean

      toggle On or Off

    • name: string

      relation name

    • Optionalvalue: string

      relation value (noteId)

    Returns void