# JSDoc: Class: Note

# Class: Note

## Note(row)

This represents a Note which is a central object in the Trilium Notes project.

## Constructor

#### new Note(row)

##### Parameters:

Name | Type | Description
--- | --- | ---
`row` |  | object containing database row from "notes" table

##### Properties:

Name | Type | Description
--- | --- | ---
`noteId` | string | primary key
`type` | string | one of "text", "code", "file" or "render"
`mime` | string | MIME type, e.g. "text/html"
`title` | string | note title
`isProtected` | boolean | true if note is protected
`isDeleted` | boolean | true if note is deleted
`deleteId` | string | null | ID identifying delete transaction
`isErased` | boolean | true if note's content is erased after it has been deleted
`dateCreated` | string | local date time (with offset)
`dateModified` | string | local date time (with offset)
`utcDateCreated` | string |
`utcDateModified` | string |

Source:
  - entities/note.js, line 32

### Extends

- Entity

### Methods

#### addAttribute() → {Attribute}

Source:
  - entities/note.js, line 531

##### Returns:

Type
  Attribute

#### getAllNotePaths() → {Array.<Array.<string>>}

Source:
  - entities/note.js, line 855

##### Returns:

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

Type
  Array.<Array.<string>>

#### getAttribute(type, name) → {Attribute}

##### Parameters:

Name | Type | Description
--- | --- | ---
`type` | string | attribute type (label, relation, etc.)
`name` | string | attribute name

Source:
  - entities/note.js, line 430

##### Returns:

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

Type
  Attribute

#### getAttributes(typeopt, nameopt) → {Array.<Attribute>}

##### Parameters:

Name | Type | Attributes | Description
--- | --- | --- | ---
`type` | string | <optional> | (optional) attribute type to filter
`name` | string | <optional> | (optional) attribute name to filter

Source:
  - entities/note.js, line 268

##### Returns:

all note's attributes, including inherited ones

Type
  Array.<Attribute>

#### getAttributeValue(type, name) → {string|null}

##### Parameters:

Name | Type | Description
--- | --- | ---
`type` | string | attribute type (label, relation, etc.)
`name` | string | attribute name

Source:
  - entities/note.js, line 441

##### Returns:

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

Type
  string | null

#### getBranches() → {Array.<Branch>}

Source:
  - entities/note.js, line 801

##### Returns:

Type
  Array.<Branch>

#### getChildBranches() → {Array.<Branch>}

Source:
  - entities/note.js, line 829

##### Returns:

child branches of this note

Type
  Array.<Branch>

#### getChildNotes() → {Array.<Note>}

Source:
  - entities/note.js, line 815

##### Returns:

child notes of this note

Type
  Array.<Note>

#### getContent() → {*}

Source:
  - entities/note.js, line 71

##### Returns:

Type
  *

#### getContentMetadata() → {Object}

Source:
  - entities/note.js, line 107

##### Returns:

Type
  Object

#### getDescendantNoteIds() → {Array.<string>}

Source:
  - entities/note.js, line 701

##### Returns:

return list of all descendant noteIds of this note. Returning just noteIds because number of notes can be huge. Includes also this note's noteId

Type
  Array.<string>

#### getDescendantNotesWithAttribute(type, name, valueopt) → {Array.<Note>}

Finds descendant notes with given attribute name and value. Only own attributes are considered, not inherited ones

##### Parameters:

Name | Type | Attributes | Description
--- | --- | --- | ---
`type` | string |  | attribute type (label, relation, etc.)
`name` | string |  | attribute name
`value` | string | <optional> | attribute value

Source:
  - entities/note.js, line 724

##### Returns:

Type
  Array.<Note>

#### getDescendantNotesWithLabel(name, valueopt) → {Array.<Note>}

Finds descendant notes with given label name and value. Only own labels are considered, not inherited ones

##### Parameters:

Name | Type | Attributes | Description
--- | --- | --- | ---
`name` | string |  | label name
`value` | string | <optional> | label value

Source:
  - entities/note.js, line 762

##### Returns:

Type
  Array.<Note>

#### getDescendantNotesWithRelation(name, valueopt) → {Array.<Note>}

Finds descendant notes with given relation name and value. Only own relations are considered, not inherited ones

##### Parameters:

Name | Type | Attributes | Description
--- | --- | --- | ---
`name` | string |  | relation name
`value` | string | <optional> | relation value

Source:
  - entities/note.js, line 771

##### Returns:

Type
  Array.<Note>

#### getJsonContent() → {*}

Source:
  - entities/note.js, line 118

##### Returns:

Type
  *

#### getLabel(name) → {Attribute|null}

##### Parameters:

Name | Type | Description
--- | --- | ---
`name` | string | label name

Source:
  - entities/note.js, line 584

##### Returns:

label if it exists, null otherwise

Type
  Attribute | null

#### getLabels(nameopt) → {Array.<Attribute>}

##### Parameters:

Name | Type | Attributes | Description
--- | --- | --- | ---
`name` | string | <optional> | label name to filter

Source:
  - entities/note.js, line 291

##### Returns:

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

Type
  Array.<Attribute>

#### getLabelValue(name) → {string|null}

##### Parameters:

Name | Type | Description
--- | --- | ---
`name` | string | label name

Source:
  - entities/note.js, line 608

##### Returns:

label value if label exists, null otherwise

Type
  string | null

#### getLinks() → {Array.<Attribute>}

Get list of links coming out of this note.

Deprecated:
  - - not intended for general use
Source:
  - entities/note.js, line 788

##### Returns:

Type
  Array.<Attribute>

#### getOwnedAttribute() → {Attribute}

Source:
  - entities/note.js, line 250

##### Returns:

attribute belonging to this specific note (excludes inherited attributes) This method can be significantly faster than the getAttribute()

Type
  Attribute

#### getOwnedAttributes(typeopt, nameopt) → {Array.<Attribute>}

This method is a faster variant of getAttributes() which looks for only owned attributes. Use when inheritance is not needed and/or in batch/performance sensitive operations.

##### Parameters:

Name | Type | Attributes | Description
--- | --- | --- | ---
`type` | string | <optional> | (optional) attribute type to filter
`name` | string | <optional> | (optional) attribute name to filter

Source:
  - entities/note.js, line 226

##### Returns:

note's "owned" attributes - excluding inherited ones

Type
  Array.<Attribute>

#### getOwnedAttributeValue(type, name) → {string|null}

##### Parameters:

Name | Type | Description
--- | --- | ---
`type` | string | attribute type (label, relation, etc.)
`name` | string | attribute name

Source:
  - entities/note.js, line 452

##### Returns:

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

Type
  string | null

#### getOwnedLabel(name) → {Attribute|null}

##### Parameters:

Name | Type | Description
--- | --- | ---
`name` | string | label name

Source:
  - entities/note.js, line 590

##### Returns:

label if it exists, null otherwise

Type
  Attribute | null

#### getOwnedLabels(nameopt) → {Array.<Attribute>}

##### Parameters:

Name | Type | Attributes | Description
--- | --- | --- | ---
`name` | string | <optional> | label name to filter

Source:
  - entities/note.js, line 299

##### Returns:

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

Type
  Array.<Attribute>

#### getOwnedLabelValue(name) → {string|null}

##### Parameters:

Name | Type | Description
--- | --- | ---
`name` | string | label name

Source:
  - entities/note.js, line 614

##### Returns:

label value if label exists, null otherwise

Type
  string | null

#### getOwnedRelation(name) → {Attribute|null}

##### Parameters:

Name | Type | Description
--- | --- | ---
`name` | string | relation name

Source:
  - entities/note.js, line 602

##### Returns:

relation if it exists, null otherwise

Type
  Attribute | null

#### getOwnedRelations(nameopt) → {Array.<Attribute>}

##### Parameters:

Name | Type | Attributes | Description
--- | --- | --- | ---
`name` | string | <optional> | relation name to filter

Source:
  - entities/note.js, line 315

##### Returns:

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

Type
  Array.<Attribute>

#### getOwnedRelationTarget(name) → {Note|null}

##### Parameters:

Name | Type | Description
--- | --- | ---
`name` | string |

Source:
  - entities/note.js, line 642

##### Returns:

target note of the relation or null (if target is empty or note was not found)

Type
  Note | null

#### getOwnedRelationValue(name) → {string|null}

##### Parameters:

Name | Type | Description
--- | --- | ---
`name` | string | relation name

Source:
  - entities/note.js, line 626

##### Returns:

relation value if relation exists, null otherwise

Type
  string | null

#### getParentNotes() → {Array.<Note>}

Source:
  - entities/note.js, line 841

##### Returns:

parent notes of this note (note can have multiple parents because of cloning)

Type
  Array.<Note>

#### getRelation(name) → {Attribute|null}

##### Parameters:

Name | Type | Description
--- | --- | ---
`name` | string | relation name

Source:
  - entities/note.js, line 596

##### Returns:

relation if it exists, null otherwise

Type
  Attribute | null

#### getRelations(nameopt) → {Array.<Attribute>}

##### Parameters:

Name | Type | Attributes | Description
--- | --- | --- | ---
`name` | string | <optional> | relation name to filter

Source:
  - entities/note.js, line 307

##### Returns:

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

Type
  Array.<Attribute>

#### getRelationTarget(name) → {Note|null}

##### Parameters:

Name | Type | Description
--- | --- | ---
`name` | string |

Source:
  - entities/note.js, line 632

##### Returns:

target note of the relation or null (if target is empty or note was not found)

Type
  Note | null

#### getRelationTargets(nameopt) → {Array.<Note>}

##### Parameters:

Name | Type | Attributes | Description
--- | --- | --- | ---
`name` | string | <optional> | relation name to filter

Source:
  - entities/note.js, line 323

##### Returns:

Type
  Array.<Note>

#### getRelationValue(name) → {string|null}

##### Parameters:

Name | Type | Description
--- | --- | ---
`name` | string | relation name

Source:
  - entities/note.js, line 620

##### Returns:

relation value if relation exists, null otherwise

Type
  string | null

#### getRevisions() → {Array.<NoteRevision>}

Returns note revisions of this note.

Source:
  - entities/note.js, line 778

##### Returns:

Type
  Array.<NoteRevision>

#### getScriptEnv() → {string}

Source:
  - entities/note.js, line 197

##### Returns:

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

Type
  string

#### getTargetRelations() → {Array.<Attribute>}

Source:
  - entities/note.js, line 259

##### Returns:

relations targetting this specific note

Type
  Array.<Attribute>

#### hasAttribute(type, name) → {boolean}

##### Parameters:

Name | Type | Description
--- | --- | ---
`type` | string | attribute type (label, relation, etc.)
`name` | string | attribute name

Source:
  - entities/note.js, line 412

##### Returns:

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

Type
  boolean

#### hasChildren() → {boolean}

Source:
  - entities/note.js, line 808

##### Returns:

- true if note has children

Type
  boolean

#### hasLabel(name) → {boolean}

##### Parameters:

Name | Type | Description
--- | --- | ---
`name` | string | label name

Source:
  - entities/note.js, line 560

##### Returns:

true if label exists (including inherited)

Type
  boolean

#### hasOwnedAttribute(type, name) → {boolean}

##### Parameters:

Name | Type | Description
--- | --- | ---
`type` | string | attribute type (label, relation, etc.)
`name` | string | attribute name

Source:
  - entities/note.js, line 421

##### Returns:

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

Type
  boolean

#### hasOwnedLabel(name) → {boolean}

##### Parameters:

Name | Type | Description
--- | --- | ---
`name` | string | label name

Source:
  - entities/note.js, line 566

##### Returns:

true if label exists (excluding inherited)

Type
  boolean

#### hasOwnedRelation(name) → {boolean}

##### Parameters:

Name | Type | Description
--- | --- | ---
`name` | string | relation name

Source:
  - entities/note.js, line 578

##### Returns:

true if relation exists (excluding inherited)

Type
  boolean

#### hasRelation(name) → {boolean}

##### Parameters:

Name | Type | Description
--- | --- | ---
`name` | string | relation name

Source:
  - entities/note.js, line 572

##### Returns:

true if relation exists (including inherited)

Type
  boolean

#### invalidateAttributeCache()

Clear note's attributes cache to force fresh reload for next attribute request. Cache is note instance scoped.

Source:
  - entities/note.js, line 338

#### isDescendantOfNote(ancestorNoteId) → {boolean}

##### Parameters:

Name | Type | Description
--- | --- | ---
`ancestorNoteId` |  |

Source:
  - entities/note.js, line 886

##### Returns:

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

Type
  boolean

#### isHtml() → {boolean}

Source:
  - entities/note.js, line 187

##### Returns:

true if this note is HTML

Type
  boolean

#### isJavaScript() → {boolean}

Source:
  - entities/note.js, line 179

##### Returns:

true if this note is JavaScript (code or attachment)

Type
  boolean

#### isJson() → {boolean}

Source:
  - entities/note.js, line 174

##### Returns:

true if this note is of application/json content type

Type
  boolean

#### isRoot() → {boolean}

Source:
  - entities/note.js, line 169

##### Returns:

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

Type
  boolean

#### isStringNote() → {boolean}

Source:
  - entities/note.js, line 192

##### Returns:

true if the note has string content (not binary)

Type
  boolean

#### removeAttribute(type, name, valueopt)

Removes given attribute name-value pair if it exists.

##### Parameters:

Name | Type | Attributes | Description
--- | --- | --- | ---
`type` | string |  | attribute type (label, relation, etc.)
`name` | string |  | attribute name
`value` | string | <optional> | attribute value (optional)

Source:
  - entities/note.js, line 515

#### removeLabel(name, valueopt)

Remove label name-value pair, if it exists.

##### Parameters:

Name | Type | Attributes | Description
--- | --- | --- | ---
`name` | string |  | label name
`value` | string | <optional> | label value

Source:
  - entities/note.js, line 688

#### removeRelation(name, valueopt)

Remove relation name-value pair, if it exists.

##### Parameters:

Name | Type | Attributes | Description
--- | --- | --- | ---
`name` | string |  | relation name
`value` | string | <optional> | relation value (noteId)

Source:
  - entities/note.js, line 696

#### setAttribute(type, name, valueopt)

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

##### Parameters:

Name | Type | Attributes | Description
--- | --- | --- | ---
`type` | string |  | attribute type (label, relation, etc.)
`name` | string |  | attribute name
`value` | string | <optional> | attribute value (optional)

Source:
  - entities/note.js, line 482

#### setLabel(name, valueopt)

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

##### Parameters:

Name | Type | Attributes | Description
--- | --- | --- | ---
`name` | string |  | label name
`value` | string | <optional> | label value

Source:
  - entities/note.js, line 672

#### setRelation(name, valueopt)

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

##### Parameters:

Name | Type | Attributes | Description
--- | --- | --- | ---
`name` | string |  | relation name
`value` | string | <optional> | relation value (noteId)

Source:
  - entities/note.js, line 680

#### toggleAttribute(type, enabled, name, valueopt)

Based on enabled, attribute is either set or removed.

##### Parameters:

Name | Type | Attributes | Description
--- | --- | --- | ---
`type` | string |  | attribute type ('relation', 'label' etc.)
`enabled` | boolean |  | toggle On or Off
`name` | string |  | attribute name
`value` | string | <optional> | attribute value (optional)

Source:
  - entities/note.js, line 466

#### toggleLabel(enabled, name, valueopt)

Based on enabled, label is either set or removed.

##### Parameters:

Name | Type | Attributes | Description
--- | --- | --- | ---
`enabled` | boolean |  | toggle On or Off
`name` | string |  | label name
`value` | string | <optional> | label value (optional)

Source:
  - entities/note.js, line 655

#### toggleRelation(enabled, name, valueopt)

Based on enabled, relation is either set or removed.

##### Parameters:

Name | Type | Attributes | Description
--- | --- | --- | ---
`enabled` | boolean |  | toggle On or Off
`name` | string |  | relation name
`value` | string | <optional> | relation value (noteId)

Source:
  - entities/note.js, line 664