abstract
AbstractAttachmentQueue<T>
Type parameters
Type parameter | Value |
---|---|
T extends AttachmentQueueOptions | AttachmentQueueOptions |
Constructors
new AbstractAttachmentQueue(options)
new AbstractAttachmentQueue<
T
>(options
):AbstractAttachmentQueue
<T
>
Parameters
Parameter | Type |
---|---|
options | T |
Returns
Source
attachments/src/AbstractAttachmentQueue.ts:48
Properties
Property | Type |
---|---|
downloadQueue | Set < string > |
downloading | boolean |
initialSync | boolean |
options | T |
uploading | boolean |
Accessors
powersync
get
protected
powersync():AbstractPowerSyncDatabase
Returns
AbstractPowerSyncDatabase
Source
attachments/src/AbstractAttachmentQueue.ts:79
storage
get
protected
storage():StorageAdapter
Returns
Source
attachments/src/AbstractAttachmentQueue.ts:83
storageDirectory
get
storageDirectory():string
Returns the directory where attachments are stored on the device, used to make dir Example: "/var/mobile/Containers/Data/Application/.../Library/attachments/"
Returns
string
Source
attachments/src/AbstractAttachmentQueue.ts:485
table
get
table():string
Returns
string
Source
attachments/src/AbstractAttachmentQueue.ts:87
Methods
clearQueue()
clearQueue():
Promise
<void
>
Returns
Promise
< void
>
Source
attachments/src/AbstractAttachmentQueue.ts:509
delete()
delete(
record
,tx
?):Promise
<void
>
Parameters
Parameter | Type |
---|---|
record | AttachmentRecord |
tx ? | Transaction |
Returns
Promise
< void
>
Source
attachments/src/AbstractAttachmentQueue.ts:209
downloadRecord()
downloadRecord(
record
):Promise
<boolean
>
Parameters
Parameter | Type |
---|---|
record | AttachmentRecord |
Returns
Promise
< boolean
>
Source
attachments/src/AbstractAttachmentQueue.ts:297
downloadRecords()
private
downloadRecords():Promise
<void
>
Returns
Promise
< void
>
Source
attachments/src/AbstractAttachmentQueue.ts:436
expireCache()
expireCache():
Promise
<void
>
Returns
Promise
< void
>
Source
attachments/src/AbstractAttachmentQueue.ts:489
getIdsToDownload()
getIdsToDownload():
Promise
<string
[] >
Returns
Promise
< string
[] >
Source
attachments/src/AbstractAttachmentQueue.ts:402
getLocalFilePathSuffix()
getLocalFilePathSuffix(
filename
):string
Returns the local file path for the given filename, used to store in the database. Example: filename: "attachment-1.jpg" returns "attachments/attachment-1.jpg"
Parameters
Parameter | Type |
---|---|
filename | string |
Returns
string
Source
attachments/src/AbstractAttachmentQueue.ts:469
getLocalUri()
getLocalUri(
filePath
):string
Return users storage directory with the attachmentPath use to load the file. Example: filePath: "attachments/attachment-1.jpg" returns "/var/mobile/Containers/Data/Application/.../Library/attachments/attachment-1.jpg"
Parameters
Parameter | Type |
---|---|
filePath | string |
Returns
string
Source
attachments/src/AbstractAttachmentQueue.ts:477
getNextUploadRecord()
getNextUploadRecord():
Promise
<AttachmentRecord
>
Returns
Promise
< AttachmentRecord
>
Source
attachments/src/AbstractAttachmentQueue.ts:237
idsToDownload()
idsToDownload(
onResult
):void
Parameters
Parameter | Type |
---|---|
onResult | (ids ) => void |
Returns
void
Source
attachments/src/AbstractAttachmentQueue.ts:415
idsToUpload()
idsToUpload(
onResult
):void
Parameters
Parameter | Type |
---|---|
onResult | (ids ) => void |
Returns
void
Source
attachments/src/AbstractAttachmentQueue.ts:349
init()
init():
Promise
<void
>
Returns
Promise
< void
>
Source
attachments/src/AbstractAttachmentQueue.ts:91
newAttachmentRecord()
abstract
newAttachmentRecord(record
?):Promise
<AttachmentRecord
>
Create a new AttachmentRecord, this gets called when the attachment id is not found in the database.
Parameters
Parameter | Type |
---|---|
record ? | Partial < AttachmentRecord > |
Returns
Promise
< AttachmentRecord
>
Source
attachments/src/AbstractAttachmentQueue.ts:77
onAttachmentIdsChange()
abstract
onAttachmentIdsChange(onUpdate
):void
Takes in a callback that gets invoked with attachment IDs that need to be synced. In most cases this will contain a watch query.
Parameters
Parameter | Type |
---|---|
onUpdate | (ids ) => void |
Returns
void
Example
onAttachmentIdsChange(onUpdate) {
this.powersync.watch('SELECT photo_id as id FROM todos WHERE photo_id IS NOT NULL', [], {
onResult: (result) => onUpdate(result.rows?._array.map((r) => r.id) ?? [])
});
}
Source
attachments/src/AbstractAttachmentQueue.ts:72
record()
record(
id
):Promise
<AttachmentRecord
>
Parameters
Parameter | Type |
---|---|
id | string |
Returns
Promise
< AttachmentRecord
>
Source
attachments/src/AbstractAttachmentQueue.ts:189
saveToQueue()
saveToQueue(
record
):Promise
<AttachmentRecord
>
Parameters
Parameter | Type |
---|---|
record | Omit < AttachmentRecord , "timestamp" > |
Returns
Promise
< AttachmentRecord
>
Source
attachments/src/AbstractAttachmentQueue.ts:167
trigger()
trigger():
void
Returns
void
Source
attachments/src/AbstractAttachmentQueue.ts:106
update()
update(
record
):Promise
<void
>
Parameters
Parameter | Type |
---|---|
record | Omit < AttachmentRecord , "timestamp" > |
Returns
Promise
< void
>
Source
attachments/src/AbstractAttachmentQueue.ts:193
uploadAttachment()
uploadAttachment(
record
):Promise
<boolean
>
Parameters
Parameter | Type |
---|---|
record | AttachmentRecord |
Returns
Promise
< boolean
>
Source
attachments/src/AbstractAttachmentQueue.ts:251
uploadRecords()
private
uploadRecords():Promise
<void
>
Returns immediately if another loop is in progress.
Returns
Promise
< void
>
Source
attachments/src/AbstractAttachmentQueue.ts:375
watchAttachmentIds()
watchAttachmentIds():
Promise
<void
>
Returns
Promise
< void
>
Source
attachments/src/AbstractAttachmentQueue.ts:112
watchDownloads()
watchDownloads():
void
Returns
void
Source
attachments/src/AbstractAttachmentQueue.ts:428
watchUploads()
watchUploads():
void
Returns
void