Class: MemorySource<QO, TO, QB, TB, QRD, TRD>
Type parameters​
Name | Type |
---|---|
QO | extends RequestOptions = RecordSourceQueryOptions |
TO | extends RequestOptions = RequestOptions |
QB | RecordQueryBuilder |
TB | RecordTransformBuilder |
QRD | unknown |
TRD | extends RecordCacheUpdateDetails = RecordCacheUpdateDetails |
Hierarchy​
RecordSource
<QO
,TO
,QB
,TB
>RecordSyncable
RecordQueryable
<QRD
,QB
,QO
>RecordUpdatable
<TRD
,TB
,TO
>↳
MemorySource
Implements​
RecordSyncable
RecordQueryable
<QRD
,QB
,QO
>RecordUpdatable
<TRD
,TB
,TO
>Resettable
Constructors​
constructor​
• new MemorySource<QO
, TO
, QB
, TB
, QRD
, TRD
>(settings
)
Type parameters​
Name | Type |
---|---|
QO | extends RequestOptions = RecordSourceQueryOptions |
TO | extends RequestOptions = RequestOptions |
QB | RecordQueryBuilder <string , RecordIdentity > |
TB | RecordTransformBuilder <string , RecordIdentity , UninitializedRecord > |
QRD | unknown |
TRD | extends RecordCacheUpdateDetails = RecordCacheUpdateDetails |
Parameters​
Name | Type |
---|---|
settings | MemorySourceSettings <QO , TO , QB , TB , QRD , TRD > |
Inherited from​
RecordSource<QO, TO, QB, TB>.constructor
Defined in​
memory/src/memory-source.ts:103
Accessors​
activated​
• get
activated(): Promise
<void
>
Returns​
Promise
<void
>
Inherited from​
RecordSource.activated
Defined in​
data/dist/modules/source.d.ts:54
base​
• get
base(): undefined
| MemorySource
<QO
, TO
, QB
, TB
, QRD
, TRD
>
Returns​
undefined
| MemorySource
<QO
, TO
, QB
, TB
, QRD
, TRD
>
Defined in​
memory/src/memory-source.ts:151
bucket​
• get
bucket(): undefined
| Bucket
<unknown
>
Returns​
undefined
| Bucket
<unknown
>
Inherited from​
RecordSource.bucket
Defined in​
data/dist/modules/source.d.ts:37
cache​
• get
cache(): MemoryCache
<QO
, TO
, QB
, TB
, QRD
, TRD
>
Returns​
MemoryCache
<QO
, TO
, QB
, TB
, QRD
, TRD
>
Defined in​
memory/src/memory-source.ts:147
defaultQueryOptions​
• get
defaultQueryOptions(): undefined
| DefaultRequestOptions
<QO
>
Returns​
undefined
| DefaultRequestOptions
<QO
>
Inherited from​
RecordSource.defaultQueryOptions
Defined in​
memory/src/memory-source.ts:477
• set
defaultQueryOptions(options
): void
Parameters​
Name | Type |
---|---|
options | undefined | DefaultRequestOptions <QO > |
Returns​
void
Inherited from​
RecordSource.defaultQueryOptions
Defined in​
memory/src/memory-source.ts:481
defaultTransformOptions​
• get
defaultTransformOptions(): undefined
| DefaultRequestOptions
<TO
>
Returns​
undefined
| DefaultRequestOptions
<TO
>
Inherited from​
RecordSource.defaultTransformOptions
Defined in​
memory/src/memory-source.ts:485
• set
defaultTransformOptions(options
): void
Parameters​
Name | Type |
---|---|
options | undefined | DefaultRequestOptions <TO > |
Returns​
void
Inherited from​
RecordSource.defaultTransformOptions
Defined in​
memory/src/memory-source.ts:489
forkPoint​
• get
forkPoint(): undefined
| string
Returns​
undefined
| string
Defined in​
memory/src/memory-source.ts:155
keyMap​
• get
keyMap(): undefined
| RecordKeyMap
Returns​
undefined
| RecordKeyMap
Inherited from​
RecordSource.keyMap
Defined in​
records/dist/modules/record-source.d.ts:57
name​
• get
name(): undefined
| string
Returns​
undefined
| string
Inherited from​
RecordSource.name
Defined in​
data/dist/modules/source.d.ts:36
queryBuilder​
• get
queryBuilder(): QB
Returns​
QB
Inherited from​
RecordSource.queryBuilder
Defined in​
records/dist/modules/record-source.d.ts:59
requestQueue​
• get
requestQueue(): TaskQueue
<string
, unknown
, unknown
, unknown
>
Returns​
TaskQueue
<string
, unknown
, unknown
, unknown
>
Inherited from​
RecordSource.requestQueue
Defined in​
data/dist/modules/source.d.ts:39
schema​
• get
schema(): RecordSchema
Returns​
RecordSchema
Inherited from​
RecordSource.schema
Defined in​
records/dist/modules/record-source.d.ts:56
syncQueue​
• get
syncQueue(): TaskQueue
<string
, unknown
, unknown
, unknown
>
Returns​
TaskQueue
<string
, unknown
, unknown
, unknown
>
Inherited from​
RecordSource.syncQueue
Defined in​
data/dist/modules/source.d.ts:40
transformBuilder​
• get
transformBuilder(): TB
Returns​
TB
Inherited from​
RecordSource.transformBuilder
Defined in​
records/dist/modules/record-source.d.ts:60
transformLog​
• get
transformLog(): Log
Returns​
Log
Inherited from​
RecordSource.transformLog
Defined in​
data/dist/modules/source.d.ts:38
validatorFor​
• get
validatorFor(): undefined
| ValidatorForFn
<StandardValidator
| StandardRecordValidator
>
Returns​
undefined
| ValidatorForFn
<StandardValidator
| StandardRecordValidator
>
Inherited from​
RecordSource.validatorFor
Defined in​
records/dist/modules/record-source.d.ts:58
Methods​
_query​
â–¸ _query(query
, hints?
): Promise
<FullResponse
<RecordQueryResult
<InitializedRecord
>, QRD
, RecordOperation
>>
Parameters​
Name | Type |
---|---|
query | RecordQuery |
hints? | ResponseHints <RecordQueryResult <InitializedRecord >, QRD > |
Returns​
Promise
<FullResponse
<RecordQueryResult
<InitializedRecord
>, QRD
, RecordOperation
>>
Inherited from​
RecordQueryable._query
Defined in​
memory/src/memory-source.ts:224
_sync​
â–¸ _sync(transform
): Promise
<void
>
Parameters​
Name | Type |
---|---|
transform | RecordTransform |
Returns​
Promise
<void
>
Inherited from​
RecordSyncable._sync
Defined in​
memory/src/memory-source.ts:167
_update​
â–¸ _update(transform
, hints?
): Promise
<FullResponse
<RecordTransformResult
<InitializedRecord
>, TRD
, RecordOperation
>>
Parameters​
Name | Type |
---|---|
transform | RecordTransform |
hints? | ResponseHints <RecordTransformResult <InitializedRecord >, TRD > |
Returns​
Promise
<FullResponse
<RecordTransformResult
<InitializedRecord
>, TRD
, RecordOperation
>>
Inherited from​
RecordUpdatable._update
Defined in​
memory/src/memory-source.ts:178
activate​
â–¸ activate(): Promise
<void
>
Returns​
Promise
<void
>
Inherited from​
RecordSource.activate
Defined in​
data/dist/modules/source.d.ts:55
allTransforms​
â–¸ allTransforms(): RecordTransform
[]
deprecated
since v0.17, call getAllTransforms
instead
Returns​
RecordTransform
[]
Defined in​
memory/src/memory-source.ts:462
deactivate​
â–¸ deactivate(): Promise
<void
>
Returns​
Promise
<void
>
Inherited from​
RecordSource.deactivate
Defined in​
data/dist/modules/source.d.ts:56
emit​
â–¸ emit(event
, ...args
): void
Parameters​
Name | Type |
---|---|
event | Event |
...args | unknown [] |
Returns​
void
Inherited from​
RecordSource.emit
Defined in​
core/dist/modules/evented.d.ts:23
fork​
â–¸ fork(settings?
): MemorySource
<QO
, TO
, QB
, TB
, QRD
, TRD
>
Create a clone, or "fork", from a "base" source.
The forked source will have the same schema
and keyMap
as its base source.
The forked source's cache will start with the same immutable document as
the base source. Its contents and log will evolve independently.
Parameters​
Name | Type |
---|---|
settings | Partial <MemorySourceSettings <QO , TO , QB , TB , QRD , TRD >> |
Returns​
MemorySource
<QO
, TO
, QB
, TB
, QRD
, TRD
>
The forked source.
Defined in​
memory/src/memory-source.ts:272
getAllTransforms​
â–¸ getAllTransforms(): RecordTransform
[]
Returns all logged transforms.
Returns​
RecordTransform
[]
Defined in​
memory/src/memory-source.ts:455
getInverseOperations​
â–¸ getInverseOperations(transformId
): RecordOperation
[]
Parameters​
Name | Type |
---|---|
transformId | string |
Returns​
RecordOperation
[]
Defined in​
memory/src/memory-source.ts:473
getQueryOptions​
â–¸ getQueryOptions(query
, expression?
): undefined
| QO
Parameters​
Name | Type |
---|---|
query | Query <QueryExpression > |
expression? | QueryExpression |
Returns​
undefined
| QO
Inherited from​
RecordSource.getQueryOptions
Defined in​
data/dist/modules/source.d.ts:47
getTransform​
â–¸ getTransform(transformId
): RecordTransform
Parameters​
Name | Type |
---|---|
transformId | string |
Returns​
RecordTransform
Defined in​
memory/src/memory-source.ts:469
getTransformOptions​
â–¸ getTransformOptions(transform
, operation?
): undefined
| TO
Parameters​
Name | Type |
---|---|
transform | Transform <Operation > |
operation? | Operation |
Returns​
undefined
| TO
Inherited from​
RecordSource.getTransformOptions
Defined in​
data/dist/modules/source.d.ts:48
getTransformsSince​
â–¸ getTransformsSince(transformId
): RecordTransform
[]
Returns all logged transforms since a particular transformId
.
Parameters​
Name | Type |
---|---|
transformId | string |
Returns​
RecordTransform
[]
Defined in​
memory/src/memory-source.ts:436
listeners​
â–¸ listeners(event
): Listener
[]
Parameters​
Name | Type |
---|---|
event | Event |
Returns​
Listener
[]
Inherited from​
RecordSource.listeners
Defined in​
core/dist/modules/evented.d.ts:24
merge​
â–¸ merge<RequestData
>(forkedSource
, options?
): Promise
<RequestData
>
Merge transforms from a forked source back into a base source.
By default, all of the operations from all of the transforms in the forked
source's history will be reduced into a single transform. A subset of
operations can be selected by specifying the sinceTransformId
option.
The coalesce
option controls whether operations are coalesced into a
minimal equivalent set before being reduced into a transform.
Type parameters​
Name | Type |
---|---|
RequestData | extends RecordTransformResult <InitializedRecord > = RecordTransformResult <InitializedRecord > |
Parameters​
Name | Type | Description |
---|---|---|
forkedSource | MemorySource <QO , TO , QB , TB , QRD , TRD > | The source to merge. |
options? | TO & { fullResponse? : false } & MemorySourceMergeOptions | Merge options |
Returns​
Promise
<RequestData
>
The result of calling update()
with the forked transforms.
Defined in​
memory/src/memory-source.ts:314
â–¸ merge<RequestData
>(forkedSource
, options
): Promise
<FullResponse
<RequestData
, TRD
, RecordOperation
>>
Type parameters​
Name | Type |
---|---|
RequestData | extends RecordTransformResult <InitializedRecord > = RecordTransformResult <InitializedRecord > |
Parameters​
Name | Type |
---|---|
forkedSource | MemorySource <QO , TO , QB , TB , QRD , TRD > |
options | TO & { fullResponse : true } & MemorySourceMergeOptions |
Returns​
Promise
<FullResponse
<RequestData
, TRD
, RecordOperation
>>
Defined in​
memory/src/memory-source.ts:318
off​
â–¸ off(event
, listener?
): void
Parameters​
Name | Type |
---|---|
event | Event |
listener? | Listener |
Returns​
void
Inherited from​
RecordSource.off
Defined in​
core/dist/modules/evented.d.ts:21
on​
â–¸ on(event
, listener
): () => void
Parameters​
Name | Type |
---|---|
event | Event |
listener | Listener |
Returns​
fn
â–¸ (): void
Returns​
void
Inherited from​
RecordSource.on
Defined in​
core/dist/modules/evented.d.ts:20
one​
â–¸ one(event
, listener
): () => void
Parameters​
Name | Type |
---|---|
event | Event |
listener | Listener |
Returns​
fn
â–¸ (): void
Returns​
void
Inherited from​
RecordSource.one
Defined in​
core/dist/modules/evented.d.ts:22
perform​
â–¸ perform(task
): Promise
<unknown
>
Parameters​
Name | Type |
---|---|
task | Task <string , unknown , unknown > |
Returns​
Promise
<unknown
>
Inherited from​
RecordSource.perform
Defined in​
data/dist/modules/source.d.ts:49
query​
â–¸ query<RequestData
>(queryOrExpressions
, options?
, id?
): Promise
<RequestData
>
Type parameters​
Name | Type |
---|---|
RequestData | extends RecordQueryResult <InitializedRecord > = RecordQueryResult <InitializedRecord > |
Parameters​
Name | Type |
---|---|
queryOrExpressions | QueryOrExpressions <RecordQueryExpression , QB > |
options? | DefaultRequestOptions <QO > |
id? | string |
Returns​
Promise
<RequestData
>
Inherited from​
RecordQueryable.query
Defined in​
data/dist/modules/queryable.d.ts:7
â–¸ query<RequestData
, RequestDetails
, RequestOperation
>(queryOrExpressions
, options
, id?
): Promise
<FullResponse
<RequestData
, RequestDetails
, RequestOperation
>>
Type parameters​
Name | Type |
---|---|
RequestData | extends RecordQueryResult <InitializedRecord > = RecordQueryResult <InitializedRecord > |
RequestDetails | QRD |
RequestOperation | extends RecordOperation = RecordOperation |
Parameters​
Name | Type |
---|---|
queryOrExpressions | QueryOrExpressions <RecordQueryExpression , QB > |
options | FullRequestOptions <QO > |
id? | string |
Returns​
Promise
<FullResponse
<RequestData
, RequestDetails
, RequestOperation
>>
Inherited from​
RecordQueryable.query
Defined in​
data/dist/modules/queryable.d.ts:8
rebase​
â–¸ rebase(): void
Rebase works similarly to a git rebase:
After a source is forked, there is a parent- and a child-source. Both may
be updated with transforms. When childSource.rebase()
is called, the
child source's state will be reset to match the current state of its
parent, and then any locally made transforms will be replayed on the child
source.
Returns​
void
Defined in​
memory/src/memory-source.ts:389
reset​
â–¸ reset(): Promise
<void
>
Reset the source's cache and transform log to its initial state, which will
be either empty or a matching its base
, if it has one.
Returns​
Promise
<void
>
Defined in​
memory/src/memory-source.ts:412
rollback​
â–¸ rollback(transformId
, relativePosition?
): Promise
<void
>
Rolls back the source to a particular transformId
.
relativePosition
can be a positive or negative integer used to specify a
position relative to transformId
.
Parameters​
Name | Type | Default value |
---|---|---|
transformId | string | undefined |
relativePosition | number | 0 |
Returns​
Promise
<void
>
Defined in​
memory/src/memory-source.ts:429
sync​
â–¸ sync(transformOrTransforms
): Promise
<void
>
The sync
method to a source. This method accepts a Transform
or array
of Transform
s as an argument and applies it to the source.
Parameters​
Name | Type |
---|---|
transformOrTransforms | Transform <RecordOperation > | Transform <RecordOperation >[] | TransformBuilderFunc <RecordOperation , RecordTransformBuilder <string , RecordIdentity , UninitializedRecord >> |
Returns​
Promise
<void
>
Inherited from​
RecordSyncable.sync
Defined in​
data/dist/modules/source-interfaces/syncable.d.ts:17
transformed​
â–¸ transformed(transforms
): Promise
<void
>
Notifies listeners that this source has been transformed by emitting the
transform
event.
Resolves when any promises returned to event listeners are resolved.
Also, adds an entry to the Source's transformLog
for each transform.
Parameters​
Name | Type |
---|---|
transforms | Transform <Operation >[] |
Returns​
Promise
<void
>
Inherited from​
RecordSource.transformed
Defined in​
data/dist/modules/source.d.ts:65
transformsSince​
â–¸ transformsSince(transformId
): RecordTransform
[]
deprecated
since v0.17, call getTransformsSince
instead
Parameters​
Name | Type |
---|---|
transformId | string |
Returns​
RecordTransform
[]
Defined in​
memory/src/memory-source.ts:445
update​
â–¸ update<RequestData
>(transformOrOperations
, options?
, id?
): Promise
<RequestData
>
Type parameters​
Name | Type |
---|---|
RequestData | extends RecordTransformResult <InitializedRecord > = RecordTransformResult <InitializedRecord > |
Parameters​
Name | Type |
---|---|
transformOrOperations | TransformOrOperations <RecordOperation , TB > |
options? | DefaultRequestOptions <TO > |
id? | string |
Returns​
Promise
<RequestData
>
Inherited from​
RecordUpdatable.update
Defined in​
data/dist/modules/updatable.d.ts:6
â–¸ update<RequestData
, RequestDetails
, RequestOperation
>(transformOrOperations
, options
, id?
): Promise
<FullResponse
<RequestData
, RequestDetails
, RequestOperation
>>
Type parameters​
Name | Type |
---|---|
RequestData | extends RecordTransformResult <InitializedRecord > = RecordTransformResult <InitializedRecord > |
RequestDetails | extends RecordCacheUpdateDetails = TRD |
RequestOperation | extends RecordOperation = RecordOperation |
Parameters​
Name | Type |
---|---|
transformOrOperations | TransformOrOperations <RecordOperation , TB > |
options | FullRequestOptions <TO > |
id? | string |
Returns​
Promise
<FullResponse
<RequestData
, RequestDetails
, RequestOperation
>>
Inherited from​
RecordUpdatable.update
Defined in​
data/dist/modules/updatable.d.ts:7
upgrade​
â–¸ upgrade(): Promise
<void
>
Returns​
Promise
<void
>
Inherited from​
RecordSource.upgrade