The method allows you to perform a bulk soft delete.
To call the method from client-side scripts, the current user must have permission to import data into the app. No additional permissions are required for server-side scripts.
An example of deleting app items:
The method allows you to permanently delete an app item.
The operation is available only for a soft-deleted item (with __deletedAt !== null).
When attempting to delete an active item, the method returns an error:
fail to hard deleteitems: cannot hard deleteitemwith id \"019db3d5-6e26-7128-bde8-f0bd222018ba\" reason: __deletedAt === null.
If the hard delete feature is disabled in your company, the method returns an error: method not available.
Example of hard deleting app Items:
const limit = 5;
let offset = 0;
let countDeleteItems = 0;
do {
const countDeleteItems = await Application.batch()
.hardDelete()
.where((f,c) => c.and (f.__deletedAt.neq(null), f.__name.like('End'))))
.size(limit)
.from(offset)
.all();
offset = offset + limit;
}
while (countDeleteItems === limit)
To call the method from client-side scripts, the current user must have permission to import data into the app. No additional permissions are required for server-side scripts.
An example of creating or updating multiple items. This is the most common approach: an array of items is created in
the memory and passed to the save function.
var items = [];
for (var i = 0; i < 500; i++) {
var item = Application.create();
items.push(item)
}
await Application.batch().save().items(items).all();
An example of creating or updating items using generators. The main difference from the previous approach is that the entire array is not stored in memory.
Items are generated one at a time, which helps
save memory.
await Application.batch().save().items((function*(){
for (var i = 0; i < 500; i++) {
var item = Application.create();
yield item
}
})()).all();
For invoking the method from client-side scripts, the current user must be granted permissions to import data in the app;
for server-side scripts, no additional permissions are required.
Example of updating app items:
Object of batch actions in an app
Type parameters
T: ItemData
P: ItemData
Hierarchy
Methods
delete
The method allows you to perform a bulk soft delete.
To call the method from client-side scripts, the current user must have permission to import data into the app. No additional permissions are required for server-side scripts. An example of deleting app items:
var rows = await Application.batch() .delete() .where (f => f.number.gte(10)) .size(100) .all();Returns ApplicationBatchDeleteBuilder<T>
hardDelete
The method allows you to permanently delete an app item.
The operation is available only for a soft-deleted item (with __deletedAt !== null). When attempting to delete an active item, the method returns an error:
fail to hard delete items: cannot hard delete item with id \"019db3d5-6e26-7128-bde8-f0bd222018ba\" reason: __deletedAt === null.If the hard delete feature is disabled in your company, the method returns an error: method not available. Example of hard deleting app Items:
const limit = 5; let offset = 0; let countDeleteItems = 0; do { const countDeleteItems = await Application.batch() .hardDelete() .where((f,c) => c.and (f.__deletedAt.neq(null), f.__name.like('End')))) .size(limit) .from(offset) .all(); offset = offset + limit; } while (countDeleteItems === limit)Returns ApplicationBatchHardDeleteBuilder<T>
save
The method allows you to run a batch save.
To call the method from client-side scripts, the current user must have permission to import data into the app. No additional permissions are required for server-side scripts. An example of creating or updating multiple items. This is the most common approach: an array of items is created in the memory and passed to the save function.
var items = []; for (var i = 0; i < 500; i++) { var item = Application.create(); items.push(item) } await Application.batch().save().items(items).all();An example of creating or updating items using generators. The main difference from the previous approach is that the entire array is not stored in memory. Items are generated one at a time, which helps save memory.
await Application.batch().save().items((function*(){ for (var i = 0; i < 500; i++) { var item = Application.create(); yield item } })()).all();Returns ApplicationBatchSaveBuilder<T, P>
setStatus
The method allows you to bulk change the status of app items.
Parameters
status: TStatus<any, any>
Optional comment: undefined | string
Returns ApplicationBatchSetStatusBuilder<T>
update
The method allows you to run a batch update.
For invoking the method from client-side scripts, the current user must be granted permissions to import data in the app; for server-side scripts, no additional permissions are required. Example of updating app items:
var rows = await Application.batch() .update() .set('number', (f, op) => 1) .set('number1' (f, op) => f.number1) .set('number2', (f, op) => op.inc (f.number, 10) .where(f => f.number.gte(10)) .size(100) .all();Returns ApplicationBatchUpdateBuilder<T, T, P>
Feedback sent successfully
Thank you for your input