Skip to main content

RNAsyncUnifiedStorage

Defined in: atomiq-storage-rn-async/src/RNAsyncUnifiedStorage.ts:12

React Native unified storage implementation using AsyncStorage as the backend. Extends MemoryIndexedKeyValueUnifiedStorage to provide indexed queries on top of AsyncStorage.

Extends​

Constructors​

Constructor​

new RNAsyncUnifiedStorage(asyncStoragePrefix, options?): RNAsyncUnifiedStorage;

Defined in: atomiq-storage-rn-async/src/RNAsyncUnifiedStorage.ts:21

Creates a new RNAsyncUnifiedStorage instance

Parameters​

ParameterTypeDescription
asyncStoragePrefixstringPrefix added to all keys to avoid collisions with other data
options?MemoryIndexedKeyValueUnifiedStorageOptionsConfiguration options for batch processing and index behavior

Returns​

RNAsyncUnifiedStorage

Overrides​

MemoryIndexedKeyValueUnifiedStorage.constructor

Properties​

compositeIndexes?​

optional compositeIndexes: UnifiedStorageCompositeIndexes;

Defined in: atomiq-storage-memory-indexed-kv/src/MemoryIndexedKeyValueUnifiedStorage.ts:92

Inherited from​

MemoryIndexedKeyValueUnifiedStorage.compositeIndexes


compositeIndexesMaps?​

optional compositeIndexesMaps: object;

Defined in: atomiq-storage-memory-indexed-kv/src/MemoryIndexedKeyValueUnifiedStorage.ts:99

Index Signature​

[compositeIndexIdentifier: string]: Map<string, Set<string>>

Inherited from​

MemoryIndexedKeyValueUnifiedStorage.compositeIndexesMaps


indexes?​

optional indexes: UnifiedStorageIndexes;

Defined in: atomiq-storage-memory-indexed-kv/src/MemoryIndexedKeyValueUnifiedStorage.ts:91

Inherited from​

MemoryIndexedKeyValueUnifiedStorage.indexes


indexesMaps?​

optional indexesMaps: object;

Defined in: atomiq-storage-memory-indexed-kv/src/MemoryIndexedKeyValueUnifiedStorage.ts:98

Index Signature​

[indexField: string]: Map<any, Set<string>>

Inherited from​

MemoryIndexedKeyValueUnifiedStorage.indexesMaps


options​

options: object;

Defined in: atomiq-storage-memory-indexed-kv/src/MemoryIndexedKeyValueUnifiedStorage.ts:94

allowQueryWithoutIndexes​

allowQueryWithoutIndexes: boolean;

maxBatchItems​

maxBatchItems: number;

Inherited from​

MemoryIndexedKeyValueUnifiedStorage.options


storageBackend​

storageBackend: AsyncStorageKeyValue;

Defined in: atomiq-storage-rn-async/src/RNAsyncUnifiedStorage.ts:14

Overrides​

MemoryIndexedKeyValueUnifiedStorage.storageBackend


writeQueue​

writeQueue: PromiseQueue;

Defined in: atomiq-storage-memory-indexed-kv/src/MemoryIndexedKeyValueUnifiedStorage.ts:101

Inherited from​

MemoryIndexedKeyValueUnifiedStorage.writeQueue

Methods​

init()​

init(indexes, compositeIndexes): Promise<void>;

Defined in: atomiq-storage-memory-indexed-kv/src/MemoryIndexedKeyValueUnifiedStorage.ts:319

Initializes the storage with given indexes and composite indexes

Parameters​

ParameterTypeDescription
indexesUnifiedStorageIndexes
compositeIndexesUnifiedStorageCompositeIndexes

Returns​

Promise<void>

Inherited from​

MemoryIndexedKeyValueUnifiedStorage.init


query()​

query(params): Promise<any[]>;

Defined in: atomiq-storage-memory-indexed-kv/src/MemoryIndexedKeyValueUnifiedStorage.ts:362

Params are specified in the following way:

  • [[condition1, condition2]] - returns all rows where condition1 AND condition2 is met
  • [[condition1], [condition2]] - returns all rows where condition1 OR condition2 is met
  • [[condition1, condition2], [condition3]] - returns all rows where (condition1 AND condition2) OR condition3 is met

You can also add an optional _meta field in the returned unified storage object which gets attached to that returned object and will be present for subsequent saves and removal of this object, if you specify the _meta field here, you need to explicitly handle it in the all the saving and remove functions and not simply serialize it into the storage

Parameters​

ParameterTypeDescription
paramsQueryParams[][]

Returns​

Promise<any[]>

Inherited from​

MemoryIndexedKeyValueUnifiedStorage.query


querySingle()​

querySingle(params): Promise<any[]>;

Defined in: atomiq-storage-memory-indexed-kv/src/MemoryIndexedKeyValueUnifiedStorage.ts:380

Queries storage with a single set of AND conditions

Parameters​

ParameterTypeDescription
paramsQueryParams[]Array of conditions that must all be met

Returns​

Promise<any[]>

Array of matching objects

Inherited from​

MemoryIndexedKeyValueUnifiedStorage.querySingle


remove()​

remove(value): Promise<void>;

Defined in: atomiq-storage-memory-indexed-kv/src/MemoryIndexedKeyValueUnifiedStorage.ts:557

Removes an object from storage

If the object contains a _meta field, this will be also present in the to-be-removed value, to mutate the _meta field of the object that is saved, you can mutate the _meta field directly on the passed value, which then gets reflected automatically in the existing object. The mutated _meta field is copied even if the function throws, hence the implementations must be careful with setting the _meta field on the still in-flight requests that might fail.

Parameters​

ParameterTypeDescription
valueanyObject to remove (must have an id property)

Returns​

Promise<void>

Inherited from​

MemoryIndexedKeyValueUnifiedStorage.remove


removeAll()​

removeAll(_values): Promise<void>;

Defined in: atomiq-storage-memory-indexed-kv/src/MemoryIndexedKeyValueUnifiedStorage.ts:578

Removes multiple objects from storage in a batch operation

If the objects contain a _meta field, this will be also present in the to-be-removed values, to mutate the _meta field of the objects that are saved, you can mutate the _meta field directly on the passed values, which then gets reflected automatically in the existing objects. The mutated _meta field is copied even if the function throws, hence the implementations must be careful with setting the _meta field on the still in-flight requests that might fail.

Parameters​

ParameterTypeDescription
_valuesany[]Array of objects to remove

Returns​

Promise<void>

Inherited from​

MemoryIndexedKeyValueUnifiedStorage.removeAll


save()​

save(value): Promise<void>;

Defined in: atomiq-storage-memory-indexed-kv/src/MemoryIndexedKeyValueUnifiedStorage.ts:472

Saves an object to storage, updating indexes as needed

If the object contains a _meta field, this will be also present in the to-be-saved value, to mutate the _meta field of the object that is saved, you can mutate the _meta field directly on the passed value, which then gets reflected automatically in the existing object. The mutated _meta field is copied even if the function throws, hence the implementations must be careful with setting the _meta field on the still in-flight requests that might fail.

Parameters​

ParameterTypeDescription
valueanyObject to save (must have an id property)

Returns​

Promise<void>

Inherited from​

MemoryIndexedKeyValueUnifiedStorage.save


saveAll()​

saveAll(_values): Promise<void>;

Defined in: atomiq-storage-memory-indexed-kv/src/MemoryIndexedKeyValueUnifiedStorage.ts:496

Saves multiple objects to storage in a batch operation

If the objects contain a _meta field, this will be also present in the to-be-saved values, to mutate the _meta field of the objects that are saved, you can mutate the _meta field directly on the passed values, which then gets reflected automatically in the existing objects. The mutated _meta field is copied even if the function throws, hence the implementations must be careful with setting the _meta field on the still in-flight requests that might fail.

Parameters​

ParameterTypeDescription
_valuesany[]Array of objects to save

Returns​

Promise<void>

Inherited from​

MemoryIndexedKeyValueUnifiedStorage.saveAll


_get()​

protected _get(key): any;

Defined in: atomiq-storage-memory-indexed-kv/src/MemoryIndexedKeyValueUnifiedStorage.ts:117

Parameters​

ParameterType
keystring

Returns​

any

Inherited from​

MemoryIndexedKeyValueUnifiedStorage._get


_getAll()​

protected _getAll(keys): any[] | Promise<any[]>;

Defined in: atomiq-storage-memory-indexed-kv/src/MemoryIndexedKeyValueUnifiedStorage.ts:126

Parameters​

ParameterType
keysstring[]

Returns​

any[] | Promise<any[]>

Inherited from​

MemoryIndexedKeyValueUnifiedStorage._getAll


_getAllSequential()​

protected _getAllSequential(keys): Promise<any[]>;

Defined in: atomiq-storage-memory-indexed-kv/src/MemoryIndexedKeyValueUnifiedStorage.ts:218

Parameters​

ParameterType
keysstring[]

Returns​

Promise<any[]>

Inherited from​

MemoryIndexedKeyValueUnifiedStorage._getAllSequential


_removeAll()​

protected _removeAll(values): void | Promise<void>;

Defined in: atomiq-storage-memory-indexed-kv/src/MemoryIndexedKeyValueUnifiedStorage.ts:183

Parameters​

ParameterType
valuesobject[]

Returns​

void | Promise<void>

Inherited from​

MemoryIndexedKeyValueUnifiedStorage._removeAll


_removeIndex()​

protected _removeIndex(
indexMap,
indexValue,
obj): void;

Defined in: atomiq-storage-memory-indexed-kv/src/MemoryIndexedKeyValueUnifiedStorage.ts:241

Parameters​

ParameterType
indexMapMap<any, Set<string>>
indexValueany
objany

Returns​

void

Inherited from​

MemoryIndexedKeyValueUnifiedStorage._removeIndex


_removeObjectIndexes()​

protected _removeObjectIndexes(obj): void;

Defined in: atomiq-storage-memory-indexed-kv/src/MemoryIndexedKeyValueUnifiedStorage.ts:273

Parameters​

ParameterType
objany

Returns​

void

Inherited from​

MemoryIndexedKeyValueUnifiedStorage._removeObjectIndexes


_saveIndex()​

protected _saveIndex(
indexMap,
indexValue,
obj): void;

Defined in: atomiq-storage-memory-indexed-kv/src/MemoryIndexedKeyValueUnifiedStorage.ts:235

Parameters​

ParameterType
indexMapMap<any, Set<string>>
indexValueany
objany

Returns​

void

Inherited from​

MemoryIndexedKeyValueUnifiedStorage._saveIndex


_saveObjectIndexes()​

protected _saveObjectIndexes(obj): void;

Defined in: atomiq-storage-memory-indexed-kv/src/MemoryIndexedKeyValueUnifiedStorage.ts:254

Parameters​

ParameterType
objany

Returns​

void

Inherited from​

MemoryIndexedKeyValueUnifiedStorage._saveObjectIndexes


_set()​

protected _set(key, value): void | Promise<void>;

Defined in: atomiq-storage-memory-indexed-kv/src/MemoryIndexedKeyValueUnifiedStorage.ts:141

Parameters​

ParameterType
keystring
valueany

Returns​

void | Promise<void>

Inherited from​

MemoryIndexedKeyValueUnifiedStorage._set


_setAll()​

protected _setAll(values): void | Promise<void>;

Defined in: atomiq-storage-memory-indexed-kv/src/MemoryIndexedKeyValueUnifiedStorage.ts:145

Parameters​

ParameterType
valuesobject[]

Returns​

void | Promise<void>

Inherited from​

MemoryIndexedKeyValueUnifiedStorage._setAll


_updateIndex()​

protected _updateIndex(
indexMap,
indexOldValue,
indexNewValue,
obj): void;

Defined in: atomiq-storage-memory-indexed-kv/src/MemoryIndexedKeyValueUnifiedStorage.ts:249

Parameters​

ParameterType
indexMapMap<any, Set<string>>
indexOldValueany
indexNewValueany
objany

Returns​

void

Inherited from​

MemoryIndexedKeyValueUnifiedStorage._updateIndex


_updateObjectIndexes()​

protected _updateObjectIndexes(obj, existingValue): void;

Defined in: atomiq-storage-memory-indexed-kv/src/MemoryIndexedKeyValueUnifiedStorage.ts:292

Parameters​

ParameterType
objany
existingValueany

Returns​

void

Inherited from​

MemoryIndexedKeyValueUnifiedStorage._updateObjectIndexes