append method
Add a new document to the current collection based on uid
.
It is possible to specify data to be added to the document by giving data
.
Implementation
@override
Future<void> append(
String uid, {
T? data,
}) async {
if (data == null) {
return;
}
if (_saveCompleter != null) {
return saving;
}
_saveCompleter = Completer<void>();
try {
await onAppend();
final val = createDocument("${path.trimQuery()}/$uid");
val.value = val.fromMap(val.filterOnLoad(val.toMap(data)));
await val.save();
await onDidAppend();
_saveCompleter?.complete();
_saveCompleter = null;
} catch (e) {
_saveCompleter?.completeError(e);
_saveCompleter = null;
} finally {
_saveCompleter?.complete();
_saveCompleter = null;
}
}