insert method

  1. @protected
bool insert(
  1. KeyId id,
  2. Object value
)

Implementation

@protected
bool insert(KeyId id, Object value) {
  var rows = _insert!.select([id.keyid, jsonEncode(value)]);
  if (!updated() || rows.length != 1) ////
    return false;
  Kind? kind = rows.first.columnAt(0) as Kind?;
  int rowid = rows.first.columnAt(1) as int;
  if (scheme.getSearchIndexesUpdater(kind) case var updaters?)
    for (var entry in updaters.toIterable()) {
      SearchRow searchRow = entry.rowGetter(value);
      entry.indexUpdater.insert.executeWith(
        StatementParameters.named({
          ...searchRowToParameters(searchRow),
          ":$columnRowId": rowid,
          ":$columnKeyId": id.keyid,
        }),
      );
      if (!updated())
        log.severe(
          "SQLite.insert: failed for rowid $rowid, kind \"$kind\","
          " search index \"${entry.indexUpdater.index.name}\"",
        );
    }
  return true;
}