replace method

  1. @override
Future<void> replace({
  1. required DocumentId docId,
  2. required T value,
})
override

Replaces the document at docId with value.

If no document exists yet, the replace will fail silently.

Requires 1 read of doc to perform replace

Implementation

@override
Future<void> replace({required DocumentId docId, required T value}) async {
  await _addToBatch((batch) async {
    final existingDoc = await collection.read(docId);

    if (existingDoc == null) return;

    batch.set(collection.ref.doc(docId.docId), value);
  });
}