put method

Future<V> put(
  1. DatabaseClient databaseClient,
  2. V value,
  3. {bool? merge}
)

Save a record, create if needed.

if merge is true and the field exists, data is merged

Returns the updated value.

Implementation

Future<V> put(DatabaseClient databaseClient, V value, {bool? merge}) async {
  var client = getClient(databaseClient);
  _checkValueArgument(value);
  value = client.sembastDatabase
      .sanitizeInputValue<V>(value as Value, update: merge);
  return (await client.inTransaction((txn) {
    return client
        .getSembastStore(store)
        .txnPut(txn, value as Value, key as Key, merge: merge);
  }) as V?)!;
}