Home Reference Source Test

Function

Static Public Summary
public

arrayEqual(a: *, b: *): boolean

public

IDSchema for when using kinto.js as a key-value store.

public

createListRequest(cid: String, store: IDBStore, filters: Object, done: Function): IDBRequest

Creates an IDB request and attach it the appropriate cursor event handler to perform a list query.

public
public

deepEqual(a: Object, b: Object): Boolean

Simple deep object comparison function.

public

async deleteDatabase(dbName: *): Promise

Helper to wrap the deletion of an IndexedDB database into a promise.

public

async execute(db: *, name: *, callback: *, options: *): Promise

Helper to run the specified callback in a single transaction on the specified store.

public

filterObject(filters: Object, entry: Object): Boolean

Test if a single object matches all given filters.

public

filterObjects(filters: Object, list: Array): Array

Filters records in a list matching all given filters.

public

importChange(transaction: IDBTransactionProxy, remote: Object, localFields: Array<String>): Object

Import a remote change into the local database.

public

makeNestedObjectFromArr(arr: *, val: *, nestedFiltersObj: *): *

public

markDeleted(record: *): *

public

markStatus(record: *, status: *): {...record: Object, "_status": *}

public

markSynced(record: *): *

public

async migrationRequired(dbName: *): *

Up to version 10.X of kinto.js, each collection had its own collection.

public

omitKeys(obj: Object, keys: Array): Object

Return an object without the specified keys.

public

async open(dbname: *, version: *, onupgradeneeded: *): Promise<IDBDatabase>

Small helper that wraps the opening of an IndexedDB into a Promise.

public

recordsEqual(a: Object, b: Object, localFields: Array): boolean

Compare two records omitting local fields and synchronization attributes (like _status and last_modified)

public

sortObjects(order: String, list: Array): Array

Sorts records in a list according to a given ordering.

public

transactionProxy(adapter: IDB, store: IDBStore, preloaded: Array): Object

IDB transaction proxy.

public

transformSubObjectFilters(filtersObj: *): *

public

waterfall(fns: Array, init: Any): Promise

Resolves a list of functions sequentially, which can be sync or async; in case of async, functions must return a promise.

Static Private Summary
private

_isUndefined(value: Any): Boolean

Checks if a value is undefined.

Static Public

public arrayEqual(a: *, b: *): boolean source

import {arrayEqual} from 'kinto/lib/utils.js'

Params:

NameTypeAttributeDescription
a *
b *

Return:

boolean

public createKeyValueStoreIdSchema(): boolean source

import {createKeyValueStoreIdSchema} from 'kinto/lib/collection.js'

IDSchema for when using kinto.js as a key-value store. Using this IDSchema requires you to set a property as the id. This will be the property used to retrieve this record.

Return:

boolean

Example:

const exampleCollection = db.collection("example", { idSchema: createKeyValueStoreIdSchema() })
await exampleCollection.create({ title: "How to tie a tie", favoriteColor: "blue", id: "user123" }, { useRecordId: true })
await exampleCollection.getAny("user123")

public createListRequest(cid: String, store: IDBStore, filters: Object, done: Function): IDBRequest source

Creates an IDB request and attach it the appropriate cursor event handler to perform a list query.

Multiple matching values are handled by passing an array.

Params:

NameTypeAttributeDescription
cid String

The collection id (ie. {bid}/{cid})

store IDBStore

The IDB store.

filters Object

Filter the records by field.

done Function

The operation completion handler.

Return:

IDBRequest

public createUUIDSchema(): * source

Return:

*

public deepEqual(a: Object, b: Object): Boolean source

import {deepEqual} from 'kinto/lib/utils.js'

Simple deep object comparison function. This only supports comparison of serializable JavaScript objects.

Params:

NameTypeAttributeDescription
a Object

The source object.

b Object

The compared object.

Return:

Boolean

public async deleteDatabase(dbName: *): Promise source

Helper to wrap the deletion of an IndexedDB database into a promise.

Params:

NameTypeAttributeDescription
dbName *

{String} the database to delete

Return:

Promise

public async execute(db: *, name: *, callback: *, options: *): Promise source

import {execute} from 'kinto/lib/adapters/IDB.js'

Helper to run the specified callback in a single transaction on the specified store. The helper focuses on transaction wrapping into a promise.

Params:

NameTypeAttributeDescription
db *

{IDBDatabase} The database instance.

name *

{String} The store name.

callback *

{Function} The piece of code to execute in the transaction.

options *

{Object} Options.

options.mode *

{String} Transaction mode (default: read).

Return:

Promise

any value returned by the callback.

public filterObject(filters: Object, entry: Object): Boolean source

import {filterObject} from 'kinto/lib/utils.js'

Test if a single object matches all given filters.

Params:

NameTypeAttributeDescription
filters Object

The filters object.

entry Object

The object to filter.

Return:

Boolean

public filterObjects(filters: Object, list: Array): Array source

import {filterObjects} from 'kinto/lib/utils.js'

Filters records in a list matching all given filters.

Params:

NameTypeAttributeDescription
filters Object

The filters object.

list Array

The collection to filter.

Return:

Array

Test:

public importChange(transaction: IDBTransactionProxy, remote: Object, localFields: Array<String>): Object source

Import a remote change into the local database.

Params:

NameTypeAttributeDescription
transaction IDBTransactionProxy

The transaction handler.

remote Object

The remote change object to import.

localFields Array<String>

The list of fields that remain local.

Return:

Object

public makeNestedObjectFromArr(arr: *, val: *, nestedFiltersObj: *): * source

Params:

NameTypeAttributeDescription
arr *
val *
nestedFiltersObj *

Return:

*

public markDeleted(record: *): * source

Params:

NameTypeAttributeDescription
record *

Return:

*

public markStatus(record: *, status: *): {...record: Object, "_status": *} source

Params:

NameTypeAttributeDescription
record *
status *

Return:

{...record: Object, "_status": *}

public markSynced(record: *): * source

Params:

NameTypeAttributeDescription
record *

Return:

*

public async migrationRequired(dbName: *): * source

Up to version 10.X of kinto.js, each collection had its own collection. The database name was ${bid}/${cid} (eg. "blocklists/certificates") and contained only one store with the same name.

Params:

NameTypeAttributeDescription
dbName *

Return:

*

public omitKeys(obj: Object, keys: Array): Object source

import {omitKeys} from 'kinto/lib/utils.js'

Return an object without the specified keys.

Params:

NameTypeAttributeDescription
obj Object

The original object.

keys Array

The list of keys to exclude.

Return:

Object

A copy without the specified keys.

public async open(dbname: *, version: *, onupgradeneeded: *): Promise<IDBDatabase> source

import {open} from 'kinto/lib/adapters/IDB.js'

Small helper that wraps the opening of an IndexedDB into a Promise.

Params:

NameTypeAttributeDescription
dbname *

{String} The database name.

version *

{Integer} Schema version

onupgradeneeded *

{Function} The callback to execute if schema is missing or different.

Return:

Promise<IDBDatabase>

public recordsEqual(a: Object, b: Object, localFields: Array): boolean source

import {recordsEqual} from 'kinto/lib/collection.js'

Compare two records omitting local fields and synchronization attributes (like _status and last_modified)

Params:

NameTypeAttributeDescription
a Object

A record to compare.

b Object

A record to compare.

localFields Array

Additional fields to ignore during the comparison

Return:

boolean

Test:

public sortObjects(order: String, list: Array): Array source

import {sortObjects} from 'kinto/lib/utils.js'

Sorts records in a list according to a given ordering.

Params:

NameTypeAttributeDescription
order String

The ordering, eg. -last_modified.

list Array

The collection to order.

Return:

Array

Test:

public transactionProxy(adapter: IDB, store: IDBStore, preloaded: Array): Object source

IDB transaction proxy.

Params:

NameTypeAttributeDescription
adapter IDB

The call IDB adapter

store IDBStore

The IndexedDB database store.

preloaded Array

The list of records to make available to get() (default: []).

Return:

Object

public transformSubObjectFilters(filtersObj: *): * source

import {transformSubObjectFilters} from 'kinto/lib/utils.js'

Params:

NameTypeAttributeDescription
filtersObj *

Return:

*

public waterfall(fns: Array, init: Any): Promise source

import {waterfall} from 'kinto/lib/utils.js'

Resolves a list of functions sequentially, which can be sync or async; in case of async, functions must return a promise.

Params:

NameTypeAttributeDescription
fns Array

The list of functions.

init Any

The initial value.

Return:

Promise

Test:

Static Private

private _isUndefined(value: Any): Boolean source

Checks if a value is undefined.

Params:

NameTypeAttributeDescription
value Any

Return:

Boolean