Back to Trilium

Class BRevision

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

0.102.212.3 KB
Original Source

Class BRevision

Revision represents a snapshot of note's title and content at some point in the past. It's used for seamless note versioning.

Hierarchy (View Summary)

Index

Constructors

constructor

Properties

blobId?content?contentLength?dateCreated?dateLastEdited?dateModified?isProtected?isSynced?mimenoteIdrevisionId?titletypeutcDateCreatedutcDateLastEdited?utcDateModified?

Accessors

beccaisDeletedentityNamehashedPropertiesprimaryKeyName

Methods

_getContent_setContentbeforeSavingeraseRevisiongenerateHashgetAttachmentByIdgetAttachmentByTitlegetAttachmentsgetAttachmentsByRolegetContentgetJsonContentgetJsonContentSafelygetNotegetPojogetPojoToSavegetUtcDateChangedhasStringContentinitisContentAvailablemarkAsDeletedmarkAsDeletedSimpleputEntityChangesavesetContentupdateFromRow

Constructors

constructor

new BRevision(row: RevisionRow, titleDecrypted?: boolean): BRevision

Parameters

Returns BRevision

Properties

OptionalblobId

blobId?: string

Optionalcontent

content?: string | Buffer<ArrayBufferLike>

OptionalcontentLength

contentLength?: number

OptionaldateCreated

dateCreated?: string

OptionaldateLastEdited

dateLastEdited?: string

OptionaldateModified

dateModified?: string

OptionalisProtected

isProtected?: boolean

OptionalisSynced

isSynced?: boolean

mime

mime: string

noteId

noteId: string

OptionalrevisionId

revisionId?: string

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

OptionalutcDateLastEdited

utcDateLastEdited?: string

OptionalutcDateModified

utcDateModified?: string

Accessors

Protectedbecca

get becca(): default

Returns default

isDeleted

get isDeleted(): boolean

Returns boolean

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

eraseRevision

eraseRevision(): void

Revisions are not soft-deletable, they are immediately hard-deleted (erased).

Returns void

generateHash

generateHash(isDeleted?: boolean): string

Parameters

  • OptionalisDeleted: boolean

Returns string

getAttachmentById

getAttachmentById(attachmentId: String, opts?: GetByIdOpts): null | BAttachment

Parameters

Returns null | BAttachment

getAttachmentByTitle

getAttachmentByTitle(title: string): BAttachment

Parameters

  • title: string

Returns BAttachment

getAttachments

getAttachments(): BAttachment[]

Returns BAttachment[]

getAttachmentsByRole

getAttachmentsByRole(role: string): BAttachment[]

Parameters

  • role: string

Returns BAttachment[]

getContent

getContent(): string | Buffer<ArrayBufferLike>

Returns string | Buffer<ArrayBufferLike>

getJsonContent

getJsonContent(): null | {}

Returns null | {}

Throws

Error in case of invalid JSON

getJsonContentSafely

getJsonContentSafely(): null | {}

Returns null | {}

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

getNote

getNote(): BNote

Returns BNote

getPojo

getPojo(): {
blobId: undefined
| string;
content: undefined | string | Buffer<ArrayBufferLike>;
contentLength: undefined | number;
dateCreated: undefined | string;
dateLastEdited: undefined | string;
isProtected: undefined | boolean;
mime: string;
noteId: string;
revisionId: undefined | string;
title: undefined | string;
type:
| "canvas"
| "code"
| "search"
| "image"
| "text"
| "file"
| "noteMap"
| "launcher"
| "doc"
| "contentWidget"
| "relationMap"
| "render"
| "mermaid"
| "book"
| "webView"
| "mindMap"
| "geoMap";
utcDateCreated: string;
utcDateLastEdited: undefined
| string;
utcDateModified: undefined | string;
}

Returns { blobId: undefined | string; content: undefined | string | Buffer<ArrayBufferLike>; contentLength: undefined | number; dateCreated: undefined | string; dateLastEdited: undefined | string; isProtected: undefined | boolean; mime: string; noteId: string; revisionId: undefined | string; title: undefined | string; type: | "canvas" | "code" | "search" | "image" | "text" | "file" | "noteMap" | "launcher" | "doc" | "contentWidget" | "relationMap" | "render" | "mermaid" | "book" | "webView" | "mindMap" | "geoMap"; utcDateCreated: string; utcDateLastEdited: undefined | string; utcDateModified: undefined | string; }

getPojoToSave

getPojoToSave(): {
blobId: undefined
| string;
content: undefined | string | Buffer<ArrayBufferLike>;
contentLength: undefined | number;
dateCreated: undefined | string;
dateLastEdited: undefined | string;
isProtected: undefined | boolean;
mime: string;
noteId: string;
revisionId: undefined | string;
title: undefined | string;
type:
| "canvas"
| "code"
| "search"
| "image"
| "text"
| "file"
| "noteMap"
| "launcher"
| "doc"
| "contentWidget"
| "relationMap"
| "render"
| "mermaid"
| "book"
| "webView"
| "mindMap"
| "geoMap";
utcDateCreated: string;
utcDateLastEdited: undefined
| string;
utcDateModified: undefined | string;
}

Returns { blobId: undefined | string; content: undefined | string | Buffer<ArrayBufferLike>; contentLength: undefined | number; dateCreated: undefined | string; dateLastEdited: undefined | string; isProtected: undefined | boolean; mime: string; noteId: string; revisionId: undefined | string; title: undefined | string; type: | "canvas" | "code" | "search" | "image" | "text" | "file" | "noteMap" | "launcher" | "doc" | "contentWidget" | "relationMap" | "render" | "mermaid" | "book" | "webView" | "mindMap" | "geoMap"; utcDateCreated: string; utcDateLastEdited: undefined | string; utcDateModified: undefined | string; }

getUtcDateChanged

getUtcDateChanged(): string

Returns string

hasStringContent

hasStringContent(): boolean

Returns boolean

true if the note has string content (not binary)

init

init(): void

Returns void

isContentAvailable

isContentAvailable(): boolean

Returns boolean

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

setContent

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

Parameters

Returns void

updateFromRow

updateFromRow(row: RevisionRow): void

Parameters

Returns void

Settings

Member Visibility

  • Protected
  • Inherited
  • External

ThemeOSLightDark

On This Page

Constructors constructor Properties blobIdcontentcontentLengthdateCreateddateLastEditeddateModifiedisProtectedisSyncedmimenoteIdrevisionIdtitletypeutcDateCreatedutcDateLastEditedutcDateModified Accessors beccaisDeletedentityNamehashedPropertiesprimaryKeyName Methods _getContent_setContentbeforeSavingeraseRevisiongenerateHashgetAttachmentByIdgetAttachmentByTitlegetAttachmentsgetAttachmentsByRolegetContentgetJsonContentgetJsonContentSafelygetNotegetPojogetPojoToSavegetUtcDateChangedhasStringContentinitisContentAvailablemarkAsDeletedmarkAsDeletedSimpleputEntityChangesavesetContentupdateFromRow