put method
Save a record, create if needed.
if ifNotExists is true, the record is only created if it does not exist.
if merge is true and the record exists, data is merged
Both merge and ifNotExists cannot be true at the same time.
Returns the updated value or existing value if ifNotExists is true and
the record exists
Implementation
Future<V> put(
DatabaseClient databaseClient,
V value, {
bool? merge,
bool? ifNotExists,
}) 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,
ifNotExists: ifNotExists,
);
})
as V?)!;
}