Documentation / @warp-drive/core / reactive / LegacyQueryArray
Interface: LegacyQueryArray<T>
Defined in: core/src/store/-private/record-arrays/legacy-query.ts:84
Legacy
QueryArrays contain the primary records returned when querying for records by ResourceType
.
Basic Example
For instance, if an application were to have a 'user'
type:
const users = await store.query('user', { name: 'Chris' });
QueryArrays are Arrays
QueryArrays have all array APIs, and will report true
for both queryArray instanceof Array
and Array.isArray(queryArray)
However, any mutation of the array will throw an error.
Reactive
If a record in a QueryArray is deleted and unloaded, it will be automatically removed from the array.
Immutable
Records cannot be directly added to or removed from a QueryArray.
Polymorphism
QueryArrays are not intended to be polymorphic. If your application has an abstract type "car" with concrete types "ferrari" and "bmw", a query which returns primary data containing both ferraris and bmws will likely work, but it is not guaranteed.
In contrast, the ReactiveResourceArray returned when using Store.request is guaranteed to work with polymorphic responses.
Memory Leaks
QueryArrays are meant to be long lived. They can be refreshed using array.update()
, and destroyed via array.destroy()
.
Unlike most Reactive state in WarpDrive, applications must choose to call destroy
when the QueryArray
is no longer needed, else the array instance will be retained until either the application or the store which created it are destroyed. Destroying a QueryArray does not remove its records from the cache, but it does remove the array as well as the overhead it requires from the store for book-keeping.
we recommend againt using QueryArrays. Use Store.request instead
Extends
Type Parameters
T
T
= unknown
Indexable
[key: number]: T
Methods
save()
save(this): Promise<LegacyArray<T>>;
Defined in: core/src/store/-private/record-arrays/-utils.ts:66
Saves all of the records in the RecordArray
.
Example
let messages = store.peekAll('message');
messages.forEach(function(message) {
message.hasBeenSeen = true;
});
messages.save();
Parameters
this
LegacyArray
<T
>
Returns
Promise
<LegacyArray
<T
>>
Inherited from
update()
update(this): Promise<LegacyArray<T>>;
Defined in: core/src/store/-private/record-arrays/-utils.ts:49
Used to get the latest version of all of the records in this array from the adapter.
Example
let people = store.peekAll('person');
people.isUpdating; // false
people.update().then(function() {
people.isUpdating; // false
});
people.isUpdating; // true
Parameters
this
LegacyArray
<T
>
Returns
Promise
<LegacyArray
<T
>>
Inherited from
Properties
isLoaded
isLoaded: boolean;
Defined in: core/src/store/-private/record-arrays/legacy-live-array.ts:75
Inherited from
isUpdating
isUpdating: boolean;
Defined in: core/src/store/-private/record-arrays/-utils.ts:26
The flag to signal a RecordArray
is currently loading data. Example
let people = store.peekAll('person');
people.isUpdating; // false
people.update();
people.isUpdating; // true
Inherited from
links
links:
| null
| Links
| PaginationLinks;
Defined in: core/src/store/-private/record-arrays/legacy-query.ts:87
meta
meta: null | ObjectValue;
Defined in: core/src/store/-private/record-arrays/legacy-query.ts:88
modelName
modelName: TypeFromInstanceOrString<T>;
Defined in: core/src/store/-private/record-arrays/legacy-live-array.ts:80
Inherited from
query
query:
| null
| Record<string, unknown>
| ImmutableRequestInfo;
Defined in: core/src/store/-private/record-arrays/legacy-query.ts:85