# 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)

- AbstractBeccaEntity < BBranch >
  - BBranch

- Defined in src/becca/entities/bbranch.ts:20

##### Index

### Constructors

constructor

### Properties

blobId?
branchId?
dateCreated?
dateModified?
isExpanded
isProtected?
isSynced?
noteId
notePosition
parentNoteId
prefix
utcDateCreated
utcDateModified?

### Accessors

becca
childNote
isDeleted
isWeak
parentNote
entityName
hashedProperties
primaryKeyName

### Methods

_getContent
_setContent
beforeSaving
createClone
deleteBranch
generateHash
getNote
getPojo
getPojoToSave
getUtcDateChanged
hasStringContent
init
markAsDeleted
markAsDeletedSimple
putEntityChange
save
update
updateFromRow

## Constructors

### constructor

- new BBranch(row?: BranchRow ): BBranch

  #### Parameters

  - `Optional` row: BranchRow

  #### Returns BBranch

  Overrides AbstractBeccaEntity.constructor

  - Defined in src/becca/entities/bbranch.ts:39

## Properties

### `Optional` blobId

blobId?: string

Inherited from AbstractBeccaEntity.blobId

- Defined in src/becca/entities/abstract_becca_entity.ts:34

### `Optional` branchId

branchId?: string

- Defined in src/becca/entities/bbranch.ts:32

### `Optional` dateCreated

dateCreated?: string

Inherited from AbstractBeccaEntity.dateCreated

- Defined in src/becca/entities/abstract_becca_entity.ts:27

### `Optional` dateModified

dateModified?: string

Inherited from AbstractBeccaEntity.dateModified

- Defined in src/becca/entities/abstract_becca_entity.ts:28

### isExpanded

isExpanded: boolean

- Defined in src/becca/entities/bbranch.ts:37

### `Optional` isProtected

isProtected?: boolean

Inherited from AbstractBeccaEntity.isProtected

- Defined in src/becca/entities/abstract_becca_entity.ts:32

### `Optional` isSynced

isSynced?: boolean

Inherited from AbstractBeccaEntity.isSynced

- Defined in src/becca/entities/abstract_becca_entity.ts:33

### noteId

noteId: string

- Defined in src/becca/entities/bbranch.ts:33

### notePosition

notePosition: number

- Defined in src/becca/entities/bbranch.ts:36

### parentNoteId

parentNoteId: string

- Defined in src/becca/entities/bbranch.ts:34

### prefix

prefix: null | string

- Defined in src/becca/entities/bbranch.ts:35

### utcDateCreated

utcDateCreated: string

Inherited from AbstractBeccaEntity.utcDateCreated

- Defined in src/becca/entities/abstract_becca_entity.ts:30

### `Optional` utcDateModified

utcDateModified?: string

Inherited from AbstractBeccaEntity.utcDateModified

- Defined in src/becca/entities/abstract_becca_entity.ts:26

## Accessors

### `Protected` becca

- get becca(): default

  #### Returns default

  Inherited from AbstractBeccaEntity.becca

  - Defined in src/becca/entities/abstract_becca_entity.ts:47

### childNote

- get childNote(): BNote

  #### Returns BNote

  - Defined in src/becca/entities/bbranch.ts:95

### isDeleted

- get isDeleted(): boolean

  #### Returns boolean

  Overrides AbstractBeccaEntity.isDeleted

  - Defined in src/becca/entities/bbranch.ts:118

### 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

  - Defined in src/becca/entities/bbranch.ts:129

### parentNote

- get parentNote(): undefined | BNote

  #### Returns undefined | BNote

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

  - Defined in src/becca/entities/bbranch.ts:109

### `Static` entityName

- get entityName(): string

  #### Returns string

  - Defined in src/becca/entities/bbranch.ts:21

### `Static` hashedProperties

- get hashedProperties(): string[]

  #### Returns string[]

  - Defined in src/becca/entities/bbranch.ts:28

### `Static` primaryKeyName

- get primaryKeyName(): string

  #### Returns string

  - Defined in src/becca/entities/bbranch.ts:24

## Methods

### `Protected`_getContent

- _getContent(): string | Buffer< ArrayBufferLike >

  #### Returns string | Buffer< ArrayBufferLike >

  Inherited from AbstractBeccaEntity._getContent

  - Defined in src/becca/entities/abstract_becca_entity.ts:261

### `Protected`_setContent

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

  #### Parameters

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

  #### Returns void

  Inherited from AbstractBeccaEntity._setContent

  - Defined in src/becca/entities/abstract_becca_entity.ts:140

### beforeSaving

- beforeSaving(): void

  #### Returns void

  Overrides AbstractBeccaEntity.beforeSaving

  - Defined in src/becca/entities/bbranch.ts:207

### createClone

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

  #### Parameters

  - parentNoteId: string
  - `Optional` notePosition: number

  #### Returns BBranch

  - Defined in src/becca/entities/bbranch.ts:263

### deleteBranch

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

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

  #### Parameters

  - `Optional` deleteId: string

    optional delete identified

  - `Optional` taskContext: TaskContext

  #### Returns boolean

  true if note has been deleted, false otherwise

  - Defined in src/becca/entities/bbranch.ts:140

### generateHash

- generateHash(isDeleted?: boolean): string

  #### Parameters

  - `Optional` isDeleted: boolean

  #### Returns string

  Inherited from AbstractBeccaEntity.generateHash

  - Defined in src/becca/entities/abstract_becca_entity.ts:63

### getNote

- getNote(): BNote

  #### Returns BNote

  - Defined in src/becca/entities/bbranch.ts:104

### 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;
  }

  Overrides AbstractBeccaEntity.getPojo

  - Defined in src/becca/entities/bbranch.ts:250

### `Protected` getPojoToSave

- getPojoToSave(): {}

  #### Returns {}

  Inherited from AbstractBeccaEntity.getPojoToSave

  - Defined in src/becca/entities/abstract_becca_entity.ts:78

### getUtcDateChanged

- getUtcDateChanged(): string

  #### Returns string

  Inherited from AbstractBeccaEntity.getUtcDateChanged

  - Defined in src/becca/entities/abstract_becca_entity.ts:43

### hasStringContent

- hasStringContent(): boolean

  #### Returns boolean

  Inherited from AbstractBeccaEntity.hasStringContent

  - Defined in src/becca/entities/abstract_becca_entity.ts:82

### init

- init(): void

  #### Returns void

  Overrides AbstractBeccaEntity.init

  - Defined in src/becca/entities/bbranch.ts:66

### 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

  Inherited from AbstractBeccaEntity.markAsDeleted

  - Defined in src/becca/entities/abstract_becca_entity.ts:277

### markAsDeletedSimple

- markAsDeletedSimple(): void

  #### Returns void

  Inherited from AbstractBeccaEntity.markAsDeletedSimple

  - Defined in src/becca/entities/abstract_becca_entity.ts:303

### `Protected` putEntityChange

- putEntityChange(isDeleted: boolean): void

  #### Parameters

  - isDeleted: boolean

  #### Returns void

  Inherited from AbstractBeccaEntity.putEntityChange

  - Defined in src/becca/entities/abstract_becca_entity.ts:51

### save

- save(opts?: {}): this

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

  #### Parameters

  - `Optional` opts: {}

  #### Returns this

  Inherited from AbstractBeccaEntity.save

  - Defined in src/becca/entities/abstract_becca_entity.ts:103

### update

- update(__namedParameters: any): BBranch

  #### Parameters

  - __namedParameters: any

  #### Returns BBranch

  - Defined in src/becca/entities/bbranch.ts:54

### updateFromRow

- updateFromRow(row: BranchRow ): void

  #### Parameters

  - row: BranchRow

  #### Returns void

  Overrides AbstractBeccaEntity.updateFromRow

  - Defined in src/becca/entities/bbranch.ts:50