restore method
Clears the deleted-at column, bringing a soft-deleted row back.
Implementation
Future<int> restore(TKey key) async {
_requireKey('restore');
final soft = binding.softDelete;
if (soft == null) {
throw StateError(
'${binding.qualifiedName} does not soft-delete, so there is nothing '
'to restore.',
);
}
final column = binding.column(soft.column)!;
final values = _stampUpdate(
MssqlWriteAssignments(<String, MssqlWriteValue>{
soft.column: MssqlBoundValue(
soft.aliveValue == null
? column.nullValue
: column.bind(soft.aliveValue),
),
}),
);
final engine = await _engine();
final outcome = await engine.updateWhere(
operation: 'restore',
values: values,
where: <MssqlCondition>[_keyCondition(key), soft.deleted],
scopes: _globalScopeConditions,
);
return outcome.affectedRows;
}