Thread
#exposed
    r

    Renaud

    1 year ago
    I have a Publication object and i’d like to insert a batch of them. Two options:1. Insert only via the Entity
    for loop
      Publication.new { ... }
    2. Insert via entity table
    Publication.table.batchInsert
    1? 2? I’m not sure
    s

    spand

    1 year ago
    One would think batchInsert would be appropriate for inserting a batch
    b

    Bogdan

    1 year ago
    well, there is not much difference. If you have Entity everywhere, then the first one. Also, if, after insertion, these Entities are used below (in a transaction), then there is no additional select in the case of the first option
    r

    Renaud

    1 year ago
    Actually there is a little difference :
    batchInsert
    returns
    List<ResultRow>
    so this can help to notify if something was inserted or not. With a “manual” loop +
    new
    we need a some sort of counter
    b

    Bogdan

    1 year ago
    sequnce { Entity.new {} }.count()