Back to Trilium

Class BBranch

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

0.102.28.3 KB
Original Source

Class BBranch

Branch represents a relationship between a child note and its parent note. Trilium allows a note to have multiple parents.

Note that you should not rely on the branch's identity, since it can change easily with a note's move. Always check noteId instead.

Hierarchy (View Summary)

Index

Constructors

constructor

Properties

blobId?branchId?dateCreated?dateModified?isExpandedisProtected?isSynced?noteIdnotePositionparentNoteIdprefixutcDateCreatedutcDateModified?

Accessors

beccachildNoteisDeletedisWeakparentNoteentityNamehashedPropertiesprimaryKeyName

Methods

_getContent_setContentbeforeSavingcreateClonedeleteBranchgenerateHashgetNotegetPojogetPojoToSavegetUtcDateChangedhasStringContentinitmarkAsDeletedmarkAsDeletedSimpleputEntityChangesaveupdateupdateFromRow

Constructors

constructor

new BBranch(row?: BranchRow): BBranch

Parameters

Returns BBranch

Properties

OptionalblobId

blobId?: string

OptionalbranchId

branchId?: string

OptionaldateCreated

dateCreated?: string

OptionaldateModified

dateModified?: string

isExpanded

isExpanded: boolean

OptionalisProtected

isProtected?: boolean

OptionalisSynced

isSynced?: boolean

noteId

noteId: string

notePosition

notePosition: number

parentNoteId

parentNoteId: string

prefix

prefix: null | string

utcDateCreated

utcDateCreated: string

OptionalutcDateModified

utcDateModified?: string

Accessors

Protectedbecca

get becca(): default

Returns default

childNote

get childNote(): BNote

Returns BNote

isDeleted

get isDeleted(): boolean

Returns boolean

isWeak

get isWeak(): boolean

Branch is weak when its existence should not hinder deletion of its note. As a result, note with only weak branches should be immediately deleted. An example is shared or bookmarked clones - they are created automatically and exist for technical reasons, not as user-intended actions. From user perspective, they don't count as real clones and for the purpose of deletion should not act as a clone.

Returns boolean

parentNote

get parentNote(): undefined | BNote

Returns undefined | BNote

root branch will have undefined parent, all other branches have to have a parent note

StaticentityName

get entityName(): string

Returns string

StatichashedProperties

get hashedProperties(): string[]

Returns string[]

StaticprimaryKeyName

get primaryKeyName(): string

Returns string

Methods

Protected_getContent

_getContent(): string | Buffer<ArrayBufferLike>

Returns string | Buffer<ArrayBufferLike>

Protected_setContent

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

Parameters

Returns void

beforeSaving

beforeSaving(): void

Returns void

createClone

createClone(parentNoteId: string, notePosition?: number): BBranch

Parameters

  • parentNoteId: string
  • OptionalnotePosition: number

Returns BBranch

deleteBranch

deleteBranch(deleteId?: string, taskContext?: TaskContext): boolean

Delete a branch. If this is a last note's branch, delete the note as well.

Parameters

  • OptionaldeleteId: string

optional delete identified

Returns boolean

true if note has been deleted, false otherwise

generateHash

generateHash(isDeleted?: boolean): string

Parameters

  • OptionalisDeleted: boolean

Returns string

getNote

getNote(): BNote

Returns BNote

getPojo

getPojo(): {
branchId: undefined
| string;
isDeleted: boolean;
isExpanded: boolean;
noteId: string;
notePosition: number;
parentNoteId: string;
prefix: null | string;
utcDateModified: undefined | string;
}

Returns { branchId: undefined | string; isDeleted: boolean; isExpanded: boolean; noteId: string; notePosition: number; parentNoteId: string; prefix: null | string; utcDateModified: undefined | string; }

ProtectedgetPojoToSave

getPojoToSave(): {}

Returns {}

getUtcDateChanged

getUtcDateChanged(): string

Returns string

hasStringContent

hasStringContent(): boolean

Returns boolean

init

init(): void

Returns void

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

save

save(opts?: {}): this

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

Parameters

  • Optionalopts: {}

Returns this

update

update(__namedParameters: any): BBranch

Parameters

  • __namedParameters: any

Returns BBranch

updateFromRow

updateFromRow(row: BranchRow): void

Parameters

Returns void

Settings

Member Visibility

  • Protected
  • Inherited
  • External

ThemeOSLightDark

On This Page

Constructors constructor Properties blobIdbranchIddateCreateddateModifiedisExpandedisProtectedisSyncednoteIdnotePositionparentNoteIdprefixutcDateCreatedutcDateModified Accessors beccachildNoteisDeletedisWeakparentNoteentityNamehashedPropertiesprimaryKeyName Methods _getContent_setContentbeforeSavingcreateClonedeleteBranchgenerateHashgetNotegetPojogetPojoToSavegetUtcDateChangedhasStringContentinitmarkAsDeletedmarkAsDeletedSimpleputEntityChangesaveupdateupdateFromRow