insert method
Inserts a new JSON value identified by the id.
If a row is inserted by insert, then this method also synchronizes the
corresponding FTS indexes and returns true.
Implementation
@protected
bool insert(KeyId id, Object value) {
var rows = _insert!.select([id.keyid, jsonToString(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 (_searchRowsUpdatersMap[kind] case var updaters?)
for (var entry in updaters.toIterable()) {
SearchRow searchRow = callSRG(entry.rowGetter, value);
entry.indexUpdater.insert.executeWith(
StatementParameters.named({
...entry.indexUpdater.index.searchRowToParameters(searchRow),
":$columnRowId": rowid,
":$columnKeyId": id.keyid,
}),
);
if (!updated())
throw JsonSqliteException(
"SQLite.insert: failed for rowid $rowid, kind \"$kind\","
" search index \"${entry.indexUpdater.index.name}\"",
);
}
return true;
}