Type parameters

Hierarchy

  • ApplicationBatcher

Methods

save

  • The method allows you to run a batch save.

    Example of inserting/updating an array of objects. The most typical method is creating an array of objects in the memory and passing it to the saving function.

    var items = [];
    for (var i = 0; i < 500; i++) {  
        var item = Application.create(); 
        items.push(item) 
    } 
    await  Application.batch().save().items(items).all(); 
    

    Example of inserting/ updating when using generators. The main difference between this and the previous method is that an entire array is not accumulated in the memory, but objects are formed when needed one item at a time, which saves 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>

update

  • The method allows you to run a batch update.

    Example of updating app objects:

    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>