Back to Trilium

Class BAttachment

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

0.102.29.8 KB
Original Source

Class BAttachment

Attachment represent data related/attached to the note. Conceptually similar to attributes, but intended for larger amounts of data and generally not accessible to the user.

Hierarchy (View Summary)

Index

Constructors

constructor

Properties

attachmentId?blobId?contentLength?dateCreated?dateModified?isDecrypted?isProtected?isSynced?mimenoteId?ownerIdposition?roletitletype?utcDateCreatedutcDateModified?utcDateScheduledForErasureSince?

Accessors

beccaisDeletedentityNamehashedPropertiesprimaryKeyName

Methods

_getContent_setContentbeforeSavingconvertToNotecopydecryptgenerateHashgetContentgetFileNamegetNotegetPojogetPojoToSavegetTitleOrProtectedgetUtcDateChangedhasStringContentinitisContentAvailablemarkAsDeletedmarkAsDeletedSimpleputEntityChangesavesetContentupdateFromRow

Constructors

constructor

new BAttachment(row: AttachmentRow): BAttachment

Parameters

Returns BAttachment

Properties

OptionalattachmentId

attachmentId?: string

OptionalblobId

blobId?: string

OptionalcontentLength

contentLength?: number

optionally added to the entity

OptionaldateCreated

dateCreated?: string

OptionaldateModified

dateModified?: string

OptionalisDecrypted

isDecrypted?: boolean

OptionalisProtected

isProtected?: boolean

OptionalisSynced

isSynced?: boolean

mime

mime: string

OptionalnoteId

noteId?: number

ownerId

ownerId: string

either noteId or revisionId to which this attachment belongs

Optionalposition

position?: number

role

role: string

title

title: string

Optionaltype

type?: "image" | "file"

utcDateCreated

utcDateCreated: string

OptionalutcDateModified

utcDateModified?: string

OptionalutcDateScheduledForErasureSince

utcDateScheduledForErasureSince?: null | 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

convertToNote

convertToNote(): { branch: BBranch; note: BNote }

Returns { branch: BBranch; note: BNote }

copy

copy(): BAttachment

Returns BAttachment

decrypt

decrypt(): void

Returns void

generateHash

generateHash(isDeleted?: boolean): string

Parameters

  • OptionalisDeleted: boolean

Returns string

getContent

getContent(): Buffer

Returns Buffer

getFileName

getFileName(): string

Returns string

getNote

getNote(): BNote

Returns BNote

getPojo

getPojo(): {
attachmentId: undefined
| string;
blobId: undefined | string;
contentLength: undefined | number;
dateModified: undefined | string;
isDeleted: boolean;
isProtected: boolean;
mime: string;
ownerId: string;
position: undefined | number;
role: string;
title: undefined | string;
utcDateModified: undefined | string;
utcDateScheduledForErasureSince: undefined | null | string;
}

Returns { attachmentId: undefined | string; blobId: undefined | string; contentLength: undefined | number; dateModified: undefined | string; isDeleted: boolean; isProtected: boolean; mime: string; ownerId: string; position: undefined | number; role: string; title: undefined | string; utcDateModified: undefined | string; utcDateScheduledForErasureSince: undefined | null | string; }

getPojoToSave

getPojoToSave(): {
attachmentId: undefined
| string;
blobId: undefined | string;
contentLength: undefined | number;
dateModified: undefined | string;
isDeleted: boolean;
isProtected: boolean;
mime: string;
ownerId: string;
position: undefined | number;
role: string;
title: undefined | string;
utcDateModified: undefined | string;
utcDateScheduledForErasureSince: undefined | null | string;
}

Returns { attachmentId: undefined | string; blobId: undefined | string; contentLength: undefined | number; dateModified: undefined | string; isDeleted: boolean; isProtected: boolean; mime: string; ownerId: string; position: undefined | number; role: string; title: undefined | string; utcDateModified: undefined | string; utcDateScheduledForErasureSince: undefined | null | string; }

getTitleOrProtected

getTitleOrProtected(): string

Returns 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: AttachmentRow): void

Parameters

Returns void

Settings

Member Visibility

  • Protected
  • Inherited
  • External

ThemeOSLightDark

On This Page

Constructors constructor Properties attachmentIdblobIdcontentLengthdateCreateddateModifiedisDecryptedisProtectedisSyncedmimenoteIdownerIdpositionroletitletypeutcDateCreatedutcDateModifiedutcDateScheduledForErasureSince Accessors beccaisDeletedentityNamehashedPropertiesprimaryKeyName Methods _getContent_setContentbeforeSavingconvertToNotecopydecryptgenerateHashgetContentgetFileNamegetNotegetPojogetPojoToSavegetTitleOrProtectedgetUtcDateChangedhasStringContentinitisContentAvailablemarkAsDeletedmarkAsDeletedSimpleputEntityChangesavesetContentupdateFromRow