Back to Trilium

Class BNote

docs/Script API/classes/Backend_Script_API.BNote.html

0.102.244.7 KB
Original Source

Class BNote

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

Hierarchy (View Summary)

Index

Constructors

constructor

Properties

__flatTextCacheblobId?childrencontentAndAttachmentsAndRevisionsSizecontentAndAttachmentsSizecontentSizedateCreated?dateModified?isBeingDeletedisDecryptedisProtected?isSynced?mimenoteIdownedAttributesparentBranchesparentsrevisionCounttargetRelationstitletypeutcDateCreatedutcDateModified?

Accessors

attributeCountbeccachildrenCountdateCreatedObjdateModifiedObjisArchivedisDeletedlabelCountownedAttributeCountownedLabelCountownedRelationCountownedRelationCountIncludingLinksparentCountrelationCountrelationCountIncludingLinkstargetRelationCounttargetRelationCountIncludingLinksutcDateCreatedObjutcDateModifiedObjentityNamehashedPropertiesprimaryKeyName

Methods

__validateTypeName_getContent_setContentaddAttributeaddLabeladdRelationareAllNotePathsArchivedbeforeSavingcloneToconvertToParentAttachmentdecryptdeleteNoteeraseExcessRevisionSnapshotsgenerateHashgetAllNotePathsgetAncestorNoteIdsgetAncestorsgetAttachmentByIdgetAttachmentByTitlegetAttachmentsgetAttachmentsByRolegetAttributegetAttributeCaseInsensitivegetAttributesgetAttributeValuegetBestNotePathgetBestNotePathStringgetBranchesgetChildBranchesgetChildNotesgetContentgetDescendantNoteIdsgetDistanceToAncestorgetFileNamegetFilteredChildBranchesgetFlatTextgetIcongetInheritingNotesgetJsonContentgetJsonContentSafelygetLabelgetLabelDefinitionsgetLabelsgetLabelValuegetLabelValuesgetOwnedAttributegetOwnedAttributesgetOwnedAttributeValuegetOwnedLabelgetOwnedLabelsgetOwnedLabelValuegetOwnedLabelValuesgetOwnedRelationgetOwnedRelationsgetOwnedRelationValuegetParentBranchesgetParentNotesgetPojogetPojoToSavegetRelationgetRelationDefinitionsgetRelationsgetRelationTargetgetRelationValuegetRevisionsgetScriptEnvgetSearchResultNotesgetSortedNotePathRecordsgetStrongParentBranchesgetSubtreegetSubtreeNoteIdsgetSubtreeNotesIncludingTemplatedgetTargetRelationsgetTitleOrProtectedgetUtcDateChangedhasAncestorhasAttributehasChildrenhasInheritableArchivedLabelhasLabelhasOwnedAttributehasOwnedLabelhasOwnedRelationhasRelationhasStringContentinitinvalidateSubTreeinvalidateThisCacheisContentAvailableisDescendantOfNoteisEligibleForConversionToAttachmentisFolderisHiddenCompletelyisHtmlisImageisInheritedisInHiddenSubtreeisJavaScriptisJsonisLabelTruthyisLaunchBarConfigisOptionsisRootisStringNotemarkAsDeletedmarkAsDeletedSimpleputEntityChangeremoveAttributeremoveLabelremoveRelationsavesaveAttachmentsaveRevisionsearchNoteInSubtreesearchNotesInSubtreesetAttributesetContentsetJsonContentsetLabelsetRelationsortChildrensortParentstoggleAttributetoggleLabeltoggleRelationupdateupdateFromRow

Constructors

constructor

new BNote(row?: Partial<NoteRow>): BNote

Parameters

Returns BNote

Properties

__flatTextCache

__flatTextCache: null | string

OptionalblobId

blobId?: string

children

children: BNote[]

contentAndAttachmentsAndRevisionsSize

contentAndAttachmentsAndRevisionsSize: null | number

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

contentAndAttachmentsSize

contentAndAttachmentsSize: null | number

size of the note content, attachment contents in bytes

contentSize

contentSize: null | number

size of the content in bytes

OptionaldateCreated

dateCreated?: string

OptionaldateModified

dateModified?: string

isBeingDeleted

isBeingDeleted: boolean

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

isDecrypted

isDecrypted: boolean

OptionalisProtected

isProtected?: boolean

OptionalisSynced

isSynced?: boolean

mime

mime: string

noteId

noteId: string

ownedAttributes

ownedAttributes: BAttribute[]

parentBranches

parentBranches: BBranch[]

parents

parents: BNote[]

revisionCount

revisionCount: null | number

number of note revisions for this note

targetRelations

targetRelations: BAttribute[]

title

title: string

type

type:
| "canvas"
| "code"
| "search"
| "image"
| "text"
| "file"
| "noteMap"
| "launcher"
| "doc"
| "contentWidget"
| "relationMap"
| "render"
| "mermaid"
| "book"
| "webView"
| "mindMap"
| "geoMap"

utcDateCreated

utcDateCreated: string

OptionalutcDateModified

utcDateModified?: string

Accessors

attributeCount

get attributeCount(): number

Returns number

Protectedbecca

get becca(): default

Returns default

childrenCount

get childrenCount(): number

Returns number

dateCreatedObj

get dateCreatedObj(): null | Dayjs

Returns null | Dayjs

dateModifiedObj

get dateModifiedObj(): null | Dayjs

Returns null | Dayjs

isArchived

get isArchived(): boolean

Returns boolean

isDeleted

get isDeleted(): boolean

Returns boolean

labelCount

get labelCount(): number

Returns number

ownedAttributeCount

get ownedAttributeCount(): number

Returns number

ownedLabelCount

get ownedLabelCount(): number

Returns number

ownedRelationCount

get ownedRelationCount(): number

Returns number

get ownedRelationCountIncludingLinks(): number

Returns number

parentCount

get parentCount(): number

Returns number

relationCount

get relationCount(): number

Returns number

get relationCountIncludingLinks(): number

Returns number

targetRelationCount

get targetRelationCount(): number

Returns number

get targetRelationCountIncludingLinks(): number

Returns number

utcDateCreatedObj

get utcDateCreatedObj(): null | Dayjs

Returns null | Dayjs

utcDateModifiedObj

get utcDateModifiedObj(): null | Dayjs

Returns null | Dayjs

StaticentityName

get entityName(): string

Returns string

StatichashedProperties

get hashedProperties(): string[]

Returns string[]

StaticprimaryKeyName

get primaryKeyName(): string

Returns string

Methods

__validateTypeName

__validateTypeName(type?: null | string, name?: null | string): void

Parameters

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

Returns void

Protected_getContent

_getContent(): string | Buffer<ArrayBufferLike>

Returns string | Buffer<ArrayBufferLike>

Protected_setContent

_setContent(content: string | Buffer<ArrayBufferLike>, opts?: ContentOpts): void

Parameters

Returns void

addAttribute

addAttribute(
type: AttributeType,
name: string,
value?: string,
isInheritable?: boolean,
position?: null | number,
): BAttribute

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

Parameters

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 BAttribute

addLabel

addLabel(name: string, value?: string, isInheritable?: boolean): BAttribute

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 BAttribute

addRelation

addRelation(
name: string,
targetNoteId: string,
isInheritable?: boolean,
): BAttribute

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 BAttribute

areAllNotePathsArchived

areAllNotePathsArchived(): boolean

Returns boolean

beforeSaving

beforeSaving(): void

Returns void

cloneTo

cloneTo(parentNoteId: string): CloneResponse

Parameters

  • parentNoteId: string

Returns CloneResponse

convertToParentAttachment

convertToParentAttachment(opts?: ConvertOpts): null | BAttachment

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

Returns null | BAttachment

null if note is not eligible for conversion

decrypt

decrypt(): void

Returns void

deleteNote

deleteNote(deleteId?: null | string, taskContext?: null | TaskContext): void

(Soft) delete a note and all its descendants.

Parameters

  • deleteId: null | string = null

optional delete identified

Returns void

eraseExcessRevisionSnapshots

eraseExcessRevisionSnapshots(): void

Returns void

generateHash

generateHash(isDeleted?: boolean): string

Parameters

  • OptionalisDeleted: boolean

Returns string

getAllNotePaths

getAllNotePaths(): string[][]

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)

getAncestorNoteIds

getAncestorNoteIds(): string[]

Returns string[]

getAncestors

getAncestors(): BNote[]

Returns BNote[]

getAttachmentById

getAttachmentById(attachmentId: string, opts?: AttachmentOpts): BAttachment

Parameters

Returns BAttachment

getAttachmentByTitle

getAttachmentByTitle(title: string): undefined | BAttachment

Parameters

  • title: string

Returns undefined | BAttachment

getAttachments

getAttachments(opts?: AttachmentOpts): BAttachment[]

Parameters

Returns BAttachment[]

getAttachmentsByRole

getAttachmentsByRole(role: string): BAttachment[]

Parameters

  • role: string

Returns BAttachment[]

getAttribute

getAttribute(type: string, name: string): null | BAttribute

Parameters

  • type: string

attribute type (label, relation, etc.)

  • name: string

attribute name

Returns null | BAttribute

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.

getAttributeCaseInsensitive

getAttributeCaseInsensitive(
type: string,
name: string,
value?: null | string,
): undefined | BAttribute

Parameters

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

Returns undefined | BAttribute

getAttributes

getAttributes(type?: string, name?: string): BAttribute[]

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 BAttribute[]

all note's attributes, including inherited ones

getAttributeValue

getAttributeValue(type: string, name: string): null | string

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.

getBestNotePath

getBestNotePath(hoistedNoteId?: string): string[]

Returns a note path considered to be the "best"

Parameters

  • hoistedNoteId: string = "root"

Returns string[]

array of noteIds constituting the particular note path

getBestNotePathString

getBestNotePathString(hoistedNoteId?: string): string

Returns a note path considered to be the "best"

Parameters

  • hoistedNoteId: string = "root"

Returns string

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

getBranches

getBranches(): BBranch[]

Returns BBranch[]

Deprecated

use getParentBranches() instead

getChildBranches

getChildBranches(): BBranch[]

Returns BBranch[]

getChildNotes

getChildNotes(): BNote[]

Returns BNote[]

getContent

getContent(): string | Buffer<ArrayBufferLike>

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>

getDescendantNoteIds

getDescendantNoteIds(): string[]

Returns string[]

Deprecated

use getSubtreeNoteIds() instead

getDistanceToAncestor

getDistanceToAncestor(ancestorNoteId: string): number

Parameters

  • ancestorNoteId: string

Returns number

getFileName

getFileName(): string

Returns string

getFilteredChildBranches

getFilteredChildBranches(): BBranch[]

Returns BBranch[]

getFlatText

getFlatText(): string

This is used for:

  • fast searching
  • note similarity evaluation

Returns string

  • returns flattened textual representation of note, prefixes and attributes

getIcon

getIcon(): string

Returns string

getInheritingNotes

getInheritingNotes(): BNote[]

Returns BNote[]

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

getJsonContent

getJsonContent(): any

Returns any

Throws

Error in case of invalid JSON

getJsonContentSafely

getJsonContentSafely(): any

Returns any

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

getLabel

getLabel(name: string): null | BAttribute

Parameters

  • name: string

label name

Returns null | BAttribute

label if it exists, null otherwise

getLabelDefinitions

getLabelDefinitions(): BAttribute[]

Returns BAttribute[]

getLabels

getLabels(name?: string): BAttribute[]

Parameters

  • Optionalname: string

label name to filter

Returns BAttribute[]

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

getLabelValue

getLabelValue(name: string): null | string

Parameters

  • name: string

label name

Returns null | string

label value if label exists, null otherwise

getLabelValues

getLabelValues(name: string): string[]

Parameters

  • name: string

label name to filter

Returns string[]

all note's label values, including inherited ones

getOwnedAttribute

getOwnedAttribute(
type: string,
name: string,
value?: null | string,
): null | BAttribute

Parameters

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

Returns null | BAttribute

attribute belonging to this specific note (excludes inherited attributes)

This method can be significantly faster than the getAttribute()

getOwnedAttributes

getOwnedAttributes(
type?: null | string,
name?: null | string,
value?: null | string,
): BAttribute[]

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 BAttribute[]

note's "owned" attributes - excluding inherited ones

getOwnedAttributeValue

getOwnedAttributeValue(type: string, name: string): null | string

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.

getOwnedLabel

getOwnedLabel(name: string): null | BAttribute

Parameters

  • name: string

label name

Returns null | BAttribute

label if it exists, null otherwise

getOwnedLabels

getOwnedLabels(name: string): BAttribute[]

Parameters

  • name: string

label name to filter

Returns BAttribute[]

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

getOwnedLabelValue

getOwnedLabelValue(name: string): null | string

Parameters

  • name: string

label name

Returns null | string

label value if label exists, null otherwise

getOwnedLabelValues

getOwnedLabelValues(name: string): string[]

Parameters

  • name: string

label name to filter

Returns string[]

all note's label values, excluding inherited ones

getOwnedRelation

getOwnedRelation(name: string): null | BAttribute

Parameters

  • name: string

relation name

Returns null | BAttribute

relation if it exists, null otherwise

getOwnedRelations

getOwnedRelations(name?: null | string): BAttribute[]

Parameters

  • Optionalname: null | string

relation name to filter

Returns BAttribute[]

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

getOwnedRelationValue

getOwnedRelationValue(name: string): null | string

Parameters

  • name: string

relation name

Returns null | string

relation value if relation exists, null otherwise

getParentBranches

getParentBranches(): BBranch[]

Returns BBranch[]

getParentNotes

getParentNotes(): BNote[]

Returns BNote[]

getPojo

getPojo(): NotePojo

Returns NotePojo

getPojoToSave

getPojoToSave(): NotePojo

Returns NotePojo

getRelation

getRelation(name: string): null | BAttribute

Parameters

  • name: string

relation name

Returns null | BAttribute

relation if it exists, null otherwise

getRelationDefinitions

getRelationDefinitions(): BAttribute[]

Returns BAttribute[]

getRelations

getRelations(name?: string): BAttribute[]

Parameters

  • Optionalname: string

relation name to filter

Returns BAttribute[]

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

getRelationTarget

getRelationTarget(name: string): undefined | null | BNote

Parameters

  • name: string

Returns undefined | null | BNote

getRelationValue

getRelationValue(name: string): null | string

Parameters

  • name: string

relation name

Returns null | string

relation value if relation exists, null otherwise

getRevisions

getRevisions(): BRevision[]

Returns BRevision[]

getScriptEnv

getScriptEnv(): null | "frontend" | "backend"

Returns null | "frontend" | "backend"

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

getSearchResultNotes

getSearchResultNotes(): BNote[]

Returns BNote[]

getSortedNotePathRecords

getSortedNotePathRecords(hoistedNoteId?: string): NotePathRecord[]

Parameters

  • hoistedNoteId: string = "root"

Returns NotePathRecord[]

getStrongParentBranches

getStrongParentBranches(): BBranch[]

Returns strong (as opposed to weak) parent branches. See isWeak for details.

Returns BBranch[]

getSubtree

getSubtree(
__namedParameters?: {
includeArchived?: boolean;
includeHidden?: boolean;
resolveSearch?: boolean;
},
): { notes: BNote[]; relationships: Relationship[] }

Parameters

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

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

getSubtreeNoteIds

getSubtreeNoteIds(
__namedParameters?: {
includeArchived?: boolean;
includeHidden?: boolean;
resolveSearch?: boolean;
},
): string[]

Parameters

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

Returns string[]

includes the subtree root note as well

getSubtreeNotesIncludingTemplated

getSubtreeNotesIncludingTemplated(): BNote[]

Returns BNote[]

getTargetRelations

getTargetRelations(): BAttribute[]

Returns BAttribute[]

getTitleOrProtected

getTitleOrProtected(): string

Returns string

getUtcDateChanged

getUtcDateChanged(): string

Returns string

hasAncestor

hasAncestor(ancestorNoteId: string): boolean

Parameters

  • ancestorNoteId: string

Returns boolean

hasAttribute

hasAttribute(type: string, name: string, value?: null | string): boolean

Parameters

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

Returns boolean

hasChildren

hasChildren(): boolean

Returns boolean

hasInheritableArchivedLabel

hasInheritableArchivedLabel(): boolean

Returns boolean

hasLabel

hasLabel(name: string, value?: string): boolean

Parameters

  • name: string

label name

  • Optionalvalue: string

label value

Returns boolean

true if label exists (including inherited)

hasOwnedAttribute

hasOwnedAttribute(type: string, name: string, value?: string): boolean

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)

hasOwnedLabel

hasOwnedLabel(name: string, value?: string): boolean

Parameters

  • name: string

label name

  • Optionalvalue: string

label value

Returns boolean

true if label exists (excluding inherited)

hasOwnedRelation

hasOwnedRelation(name: string, value?: string): boolean

Parameters

  • name: string

relation name

  • Optionalvalue: string

relation value

Returns boolean

true if relation exists (excluding inherited)

hasRelation

hasRelation(name: string, value?: string): boolean

Parameters

  • name: string

relation name

  • Optionalvalue: string

relation value

Returns boolean

true if relation exists (including inherited)

hasStringContent

hasStringContent(): boolean

Returns boolean

true if the note has string content (not binary)

init

init(): void

Returns void

invalidateSubTree

invalidateSubTree(path?: string[]): void

Parameters

  • path: string[] = []

Returns void

invalidateThisCache

invalidateThisCache(): void

Returns void

isContentAvailable

isContentAvailable(): boolean

Returns boolean

isDescendantOfNote

isDescendantOfNote(ancestorNoteId: string): boolean

Parameters

  • ancestorNoteId: string

Returns boolean

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

isEligibleForConversionToAttachment

isEligibleForConversionToAttachment(opts?: ConvertOpts): boolean

Parameters

Returns boolean

isFolder

isFolder(): boolean

Returns boolean

isHiddenCompletely

isHiddenCompletely(): boolean

Returns boolean

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

isHtml

isHtml(): boolean

Returns boolean

true if this note is HTML

isImage

isImage(): boolean

Returns boolean

true if this note is an image

isInherited

isInherited(): boolean

Returns boolean

isInHiddenSubtree

isInHiddenSubtree(): boolean

Returns boolean

isJavaScript

isJavaScript(): boolean

Returns boolean

true if this note is JavaScript (code or attachment)

isJson

isJson(): boolean

Returns boolean

true if this note is of application/json content type

isLabelTruthy

isLabelTruthy(name: string): boolean

Parameters

  • name: string

label name

Returns boolean

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

isLaunchBarConfig

isLaunchBarConfig(): boolean

Returns boolean

isOptions

isOptions(): boolean

Returns boolean

isRoot

isRoot(): boolean

Returns boolean

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

isStringNote

isStringNote(): boolean

Returns boolean

Deprecated

use hasStringContent() instead

markAsDeleted

markAsDeleted(deleteId?: null | string): void

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

markAsDeletedSimple

markAsDeletedSimple(): void

Returns void

ProtectedputEntityChange

putEntityChange(isDeleted: boolean): void

Parameters

  • isDeleted: boolean

Returns void

removeAttribute

removeAttribute(type: string, name: string, value?: string): 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

removeLabel

removeLabel(name: string, value?: string): void

Remove label name-value pair, if it exists.

Parameters

  • name: string

label name

  • Optionalvalue: string

label value

Returns void

removeRelation

removeRelation(name: string, value?: string): void

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

Parameters

  • name: string

relation name

  • Optionalvalue: string

relation value (noteId)

Returns void

save

save(opts?: {}): this

Saves entity - executes SQL, but doesn't commit the transaction on its own

Parameters

  • Optionalopts: {}

Returns this

saveAttachment

saveAttachment(
__namedParameters: AttachmentRow,
matchBy?: undefined | "title" | "attachmentId",
): BAttachment

Parameters

  • __namedParameters: AttachmentRow
  • matchBy: undefined | "title" | "attachmentId" = "attachmentId"

choose by which property we detect if to update an existing attachment. Supported values are either 'attachmentId' (default) or 'title'

Returns BAttachment

saveRevision

saveRevision(): BRevision

Returns BRevision

searchNoteInSubtree

searchNoteInSubtree(searchString: string): BNote

Parameters

  • searchString: string

Returns BNote

searchNotesInSubtree

searchNotesInSubtree(searchString: string): BNote[]

Parameters

  • searchString: string

Returns BNote[]

setAttribute

setAttribute(type: AttributeType, name: string, value?: string): void

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

Parameters

attribute type (label, relation, etc.)

  • name: string

attribute name

  • Optionalvalue: string

attribute value (optional)

Returns void

setContent

setContent(content: string | Buffer<ArrayBufferLike>, opts?: ContentOpts): void

Parameters

Returns void

setJsonContent

setJsonContent(content: {}): void

Parameters

  • content: {}

Returns void

setLabel

setLabel(name: string, value?: string): 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

setRelation

setRelation(name: string, value?: string): 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

sortChildren

sortChildren(): void

Returns void

sortParents

sortParents(): void

Returns void

toggleAttribute

toggleAttribute(
type: AttributeType,
enabled: boolean,
name: string,
value?: string,
): void

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

Parameters

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

  • enabled: boolean

toggle On or Off

  • name: string

attribute name

  • Optionalvalue: string

attribute value (optional)

Returns void

toggleLabel

toggleLabel(enabled: boolean, name: string, value?: string): 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

toggleRelation

toggleRelation(enabled: boolean, name: string, value?: string): 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

update

update(__namedParameters: any): BNote

Parameters

  • __namedParameters: any

Returns BNote

updateFromRow

updateFromRow(row: Partial<NoteRow>): void

Parameters

Returns void

Settings

Member Visibility

  • Protected
  • Inherited
  • External

ThemeOSLightDark

On This Page

Constructors constructor Properties __flatTextCacheblobIdchildrencontentAndAttachmentsAndRevisionsSizecontentAndAttachmentsSizecontentSizedateCreateddateModifiedisBeingDeletedisDecryptedisProtectedisSyncedmimenoteIdownedAttributesparentBranchesparentsrevisionCounttargetRelationstitletypeutcDateCreatedutcDateModified Accessors attributeCountbeccachildrenCountdateCreatedObjdateModifiedObjisArchivedisDeletedlabelCountownedAttributeCountownedLabelCountownedRelationCountownedRelationCountIncludingLinksparentCountrelationCountrelationCountIncludingLinkstargetRelationCounttargetRelationCountIncludingLinksutcDateCreatedObjutcDateModifiedObjentityNamehashedPropertiesprimaryKeyName Methods __validateTypeName_getContent_setContentaddAttributeaddLabeladdRelationareAllNotePathsArchivedbeforeSavingcloneToconvertToParentAttachmentdecryptdeleteNoteeraseExcessRevisionSnapshotsgenerateHashgetAllNotePathsgetAncestorNoteIdsgetAncestorsgetAttachmentByIdgetAttachmentByTitlegetAttachmentsgetAttachmentsByRolegetAttributegetAttributeCaseInsensitivegetAttributesgetAttributeValuegetBestNotePathgetBestNotePathStringgetBranchesgetChildBranchesgetChildNotesgetContentgetDescendantNoteIdsgetDistanceToAncestorgetFileNamegetFilteredChildBranchesgetFlatTextgetIcongetInheritingNotesgetJsonContentgetJsonContentSafelygetLabelgetLabelDefinitionsgetLabelsgetLabelValuegetLabelValuesgetOwnedAttributegetOwnedAttributesgetOwnedAttributeValuegetOwnedLabelgetOwnedLabelsgetOwnedLabelValuegetOwnedLabelValuesgetOwnedRelationgetOwnedRelationsgetOwnedRelationValuegetParentBranchesgetParentNotesgetPojogetPojoToSavegetRelationgetRelationDefinitionsgetRelationsgetRelationTargetgetRelationValuegetRevisionsgetScriptEnvgetSearchResultNotesgetSortedNotePathRecordsgetStrongParentBranchesgetSubtreegetSubtreeNoteIdsgetSubtreeNotesIncludingTemplatedgetTargetRelationsgetTitleOrProtectedgetUtcDateChangedhasAncestorhasAttributehasChildrenhasInheritableArchivedLabelhasLabelhasOwnedAttributehasOwnedLabelhasOwnedRelationhasRelationhasStringContentinitinvalidateSubTreeinvalidateThisCacheisContentAvailableisDescendantOfNoteisEligibleForConversionToAttachmentisFolderisHiddenCompletelyisHtmlisImageisInheritedisInHiddenSubtreeisJavaScriptisJsonisLabelTruthyisLaunchBarConfigisOptionsisRootisStringNotemarkAsDeletedmarkAsDeletedSimpleputEntityChangeremoveAttributeremoveLabelremoveRelationsavesaveAttachmentsaveRevisionsearchNoteInSubtreesearchNotesInSubtreesetAttributesetContentsetJsonContentsetLabelsetRelationsortChildrensortParentstoggleAttributetoggleLabeltoggleRelationupdateupdateFromRow