# 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
`content` | string | note content - e.g. HTML text for text notes, file payload for files
`isProtected` | boolean | true if note is protected
`isDeleted` | boolean | true if note is deleted
`dateCreated` | string |
`dateModified` | string |

Source:
  - entities/note.js, line 27

### Extends

- Entity

### Methods

#### (async) findNotesWithAttribute(type, name, valueopt) → {Promise.<Array.<Note>>}

Finds 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 399

##### Returns:

Type
  Promise.<Array.<Note>>

#### (async) findNotesWithLabel(name, valueopt) → {Promise.<Array.<Note>>}

Finds 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 437

##### Returns:

Type
  Promise.<Array.<Note>>

#### (async) findNotesWithRelation(name, valueopt) → {Promise.<Array.<Note>>}

Finds 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 446

##### Returns:

Type
  Promise.<Array.<Note>>

#### (async) getAttribute(type, name) → {Promise.<Attribute>}

##### Parameters:

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

Source:
  - entities/note.js, line 207

##### 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
  Promise.<Attribute>

#### (async) getAttributes() → {Promise.<Array.<Attribute>>}

Source:
  - entities/note.js, line 103

##### Returns:

all note's attributes, including inherited ones

Type
  Promise.<Array.<Attribute>>

#### (async) getAttributeValue(type, name) → {Promise.<string>}

##### Parameters:

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

Source:
  - entities/note.js, line 218

##### Returns:

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

Type
  Promise.<string>

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

Source:
  - entities/note.js, line 467

##### Returns:

Type
  Promise.<Array.<Branch>>

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

Source:
  - entities/note.js, line 488

##### Returns:

child branches of this note

Type
  Promise.<Array.<Branch>>

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

Source:
  - entities/note.js, line 474

##### Returns:

child notes of this note

Type
  Promise.<Array.<Note>>

#### (async) getLabel(name) → {Promise.<Attribute>}

##### Parameters:

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

Source:
  - entities/note.js, line 305

##### Returns:

label if it exists, null otherwise

Type
  Promise.<Attribute>

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

Source:
  - entities/note.js, line 112

##### Returns:

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

Type
  Promise.<Array.<Attribute>>

#### (async) getLabelValue(name) → {Promise.<string>}

##### Parameters:

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

Source:
  - entities/note.js, line 317

##### Returns:

label value if label exists, null otherwise

Type
  Promise.<string>

#### (async) getNoteImages() → {Promise.<Array.<NoteImage>>}

Source:
  - entities/note.js, line 460

##### Returns:

Type
  Promise.<Array.<NoteImage>>

#### (async) getOwnedAttributes() → {Promise.<Array.<Attribute>>}

Source:
  - entities/note.js, line 98

##### Returns:

attributes belonging to this specific note (excludes inherited attributes)

Type
  Promise.<Array.<Attribute>>

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

Source:
  - entities/note.js, line 500

##### Returns:

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

Type
  Promise.<Array.<Note>>

#### (async) getRelation(name) → {Promise.<Attribute>}

##### Parameters:

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

Source:
  - entities/note.js, line 311

##### Returns:

relation if it exists, null otherwise

Type
  Promise.<Attribute>

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

Source:
  - entities/note.js, line 117

##### Returns:

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

Type
  Promise.<Array.<Attribute>>

#### (async) getRelationTarget(name) → {Promise.<Note>|null}

##### Parameters:

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

Source:
  - entities/note.js, line 385

##### Returns:

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

Type
  Promise.<Note> | null

#### (async) getRelationValue(name) → {Promise.<string>}

##### Parameters:

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

Source:
  - entities/note.js, line 323

##### Returns:

relation value if relation exists, null otherwise

Type
  Promise.<string>

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

Returns note revisions of this note.

Source:
  - entities/note.js, line 453

##### Returns:

Type
  Promise.<Array.<NoteRevision>>

#### getScriptEnv() → {string}

Source:
  - entities/note.js, line 79

##### Returns:

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

Type
  string

#### (async) hasAttribute(type, name) → {Promise.<boolean>}

##### Parameters:

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

Source:
  - entities/note.js, line 198

##### Returns:

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

Type
  Promise.<boolean>

#### (async) hasLabel(name) → {Promise.<boolean>}

##### Parameters:

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

Source:
  - entities/note.js, line 293

##### Returns:

true if label exists (including inherited)

Type
  Promise.<boolean>

#### (async) hasRelation(name) → {Promise.<boolean>}

##### Parameters:

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

Source:
  - entities/note.js, line 299

##### Returns:

true if relation exists (including inherited)

Type
  Promise.<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 125

#### isHtml() → {boolean}

Source:
  - entities/note.js, line 74

##### Returns:

true if this note is HTML

Type
  boolean

#### isJavaScript() → {boolean}

Source:
  - entities/note.js, line 68

##### Returns:

true if this note is JavaScript (code or attachment)

Type
  boolean

#### isJson() → {boolean}

Source:
  - entities/note.js, line 63

##### Returns:

true if this note is of application/json content type

Type
  boolean

#### isRoot() → {boolean}

Source:
  - entities/note.js, line 58

##### Returns:

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

Type
  boolean

#### (async) loadAttributesToCache() → {Promise.<void>}

Source:
  - entities/note.js, line 130

##### Returns:

Type
  Promise.<void>

#### (async) removeAttribute(type, name, valueopt) → {Promise.<void>}

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 276

##### Returns:

Type
  Promise.<void>

#### (async) removeLabel(name, valueopt) → {Promise.<void>}

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 370

##### Returns:

Type
  Promise.<void>

#### (async) removeRelation(name, valueopt) → {Promise.<void>}

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 379

##### Returns:

Type
  Promise.<void>

#### (async) setAttribute(type, name, valueopt) → {Promise.<void>}

Creates given attribute name-value pair 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 250

##### Returns:

Type
  Promise.<void>

#### (async) setLabel(name, valueopt) → {Promise.<void>}

Create label name-value pair if it doesn't exist yet.

##### Parameters:

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

Source:
  - entities/note.js, line 352

##### Returns:

Type
  Promise.<void>

#### (async) setRelation(name, valueopt) → {Promise.<void>}

Create relation name-value pair if it doesn't exist yet.

##### Parameters:

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

Source:
  - entities/note.js, line 361

##### Returns:

Type
  Promise.<void>

#### (async) toggleAttribute(type, enabled, name, valueopt) → {Promise.<void>}

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 233

##### Returns:

Type
  Promise.<void>

#### (async) toggleLabel(enabled, name, valueopt) → {Promise.<void>}

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 333

##### Returns:

Type
  Promise.<void>

#### (async) toggleRelation(enabled, name, valueopt) → {Promise.<void>}

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 343

##### Returns:

Type
  Promise.<void>