Skip to content

Latest commit

 

History

History
205 lines (119 loc) · 5.32 KB

File metadata and controls

205 lines (119 loc) · 5.32 KB

collection-sync / Exports / Collection

Interface: Collection

This interface defines several CRUD methods to operate on a collection. These methods can be implemented by accessing a local database, requesting a restful API (remote DB), etc.

Hierarchy

Implemented by

Table of contents

Methods

Methods

commitSync

commitSync(itemsToSync, ignoredItems, conflictItems): Promise<boolean>

Commits the sync operation. Database engines that don't support this should implement a method that returns true (because the data was already added without the need for a commit statement). Make sure to commit the data from one specific sync process in order to avoid committing data pushed by multiple users synchronizing at the same time.

Parameters

Name Type
itemsToSync SyncItem[]
ignoredItems SyncItem[]
conflictItems SyncItem[]

Returns

Promise<boolean>

Defined in

Collection.ts:44


countAll

countAll(): number | Promise<number>

Gets the number of items in the collection.

Returns

number | Promise<number>

Defined in

Collection.ts:11


findByIds

findByIds(ids): SyncItem[] | Promise<SyncItem[]>

Returns a list of records using an ID list as search query.

Parameters

Name Type
ids DocId[]

Returns

SyncItem[] | Promise<SyncItem[]>

Defined in

Collection.ts:14


initialize

initialize(): Promise<void>

Executes async logic to initialize collection or datastore (open file, create database connection, etc).

Returns

Promise<void>

Inherited from

IInitializable.initialize

Defined in

IInitializable.ts:3


itemsNewerThan

itemsNewerThan(date, limit): SyncItem[] | Promise<SyncItem[]>

Returns a list of items that have updatedAt greater than argument provided. The list MUST be ordered by updatedAt ASC, otherwise an exception will be thrown (no syncing will be executed).

Parameters

Name Type
date undefined | Date
limit number

Returns

SyncItem[] | Promise<SyncItem[]>

Defined in

Collection.ts:26


latestUpdatedItem

latestUpdatedItem(): undefined | SyncItem | Promise<undefined | SyncItem>

Gets the highest updateAt date in the collection.

Returns

undefined | SyncItem | Promise<undefined | SyncItem>

Defined in

Collection.ts:31


rollbackSync

rollbackSync(itemsToSync, ignoredItems, conflictItems): void | Promise<void>

Rollbacks the current data that's being synchronized. Make sure to rollback the data from one specific sync process in order to avoid discarding data pushed by multiple users synchronizing at the same time.

Parameters

Name Type
itemsToSync SyncItem[]
ignoredItems SyncItem[]
conflictItems SyncItem[]

Returns

void | Promise<void>

Defined in

Collection.ts:51


syncBatch

syncBatch(items): SyncItem[] | Promise<SyncItem[]>

Syncs (upsert/delete) a batch (list) of items into this collection. Order of document processing doesn't need to be in any particular order.

Parameters

Name Type
items SyncItem[]

Returns

SyncItem[] | Promise<SyncItem[]>

Defined in

Collection.ts:20