Type parameters
Hierarchy
-
ApplicationBatchUpdateBuilder<TFull, T, P>
- ApplicationBatchUpdater
Methods
all
-
The method runs a batch update.
Returns the number of items that were actually updated according to ApplicationBatchUpdater.size, starting from [[ApplicationBatchUpdater. from]]. By default, the size of the updated items is limited to 10 entries. If you need to update more items, use the ApplicationBatchUpdater.size method.
const searchResults = await Application.update() .set('str', _ => 'test') .where((f, g) => g.and ( f. __deletedAt.eq(null), f.str.eq(null) )) .all();
Returns Promise<number>
from
-
The method allows skipping the set number of updated items.
Parameters
-
n: number
Number of items to skip. For example, when working with a large number of app items, you can divide the update into separate batches and dynamically determine the start of each batch.
Context.data.from += 100; const rows = await Application.batch() .update() .set('str', _ => 'test') .from(Context.data.from) .where((f, g) => g.and ( f.__deletedAt.eq(null), f.str.eq(null) )) .all();
Returns this
-
notify
-
The method sets notifications for when app items are updated.
Parameters
-
enabled: boolean
If
enabled
is set totrue
, notifications are enabled. By default they are disabled. Important: enabling notifications when updating a large number of items can cause excessive load on the system. For each item, an update event will be created that is then processed in the system in general order.const rows = await Application.batch(). update().set('str', _ => 'test') .notify(true) .all();
Returns this
-
set
-
The method allows setting rules for updating fields of app items in a collection.
Type parameters
-
K: keyof UpdatableItem<T>
Parameters
-
f: K
Name of the app item field that is being updated.
-
v: UpdateClosure<UpdatableItem<TFull>, RemoveIndex<T>[K]>
Value of the updated field.
const rows = await Application. batch() .update() .set('str0', _ => 'test') .set('str1', f => f.str) .set('str2', (f, op) => op.concat(f.str0, '+', f.str1)) . all();
Returns ApplicationBatchUpdater<TFull, Omit<RemoveIndex<T>, K>, P>
-
size
-
The method allows to limit the number of updated items.
Parameters
-
n: number
Batch size (default size is 10, the max size is 10000).
const rows = await Application.batch() .update() .set('str', _ => 'test') .size(500) .where((f, g) => g.and ( f.__deletedAt. eq(null), f.str.eq(null) )) .all();
Returns this
-
where
-
The method allows setting filtering for updated app items in a collection.
Parameters
-
fc: FilterClosure<TFull>
Search filters.
const rows = await Application.batch() . update() .set('str', _ => 'test') .where((f, g) => g.and ( f.__deletedAt.eq(null), f.str.eq(null) )) .all();
Returns this
-
Object of app item update
ApplicationBatchUpdater allows you to do basic configuration of batch update: