mergeWhere method

E mergeWhere(
  1. UpdateOrFn<E> updateOrFn,
  2. Where<E> where
)

UPSERT: 있으면 UPDATE, 없으면 INSERT

Implementation

E mergeWhere(UpdateOrFn<E> updateOrFn, Where<E> where) {
  int index = indexWhere(where);

  if (index == -1) {
    var inserted = updateOrFn(null);
    add(inserted);
    return inserted;
  } else {
    this[index] = updateOrFn(this[index]);
    return this[index];
  }
}