add method
Given item
will be added to the collection with name type
,
which is inside the document parent
. If parent
is null,
global collection with name type
will be used to store the item
.
Will return the DocumentReference
that was used to store item
.
Implementation
Future<DocumentReference> add({
required T item,
SetOptions? setOptions,
required String type,
DocumentReference? parent,
}) async {
final data = toMap(item, setOptions);
final ref = _merge(type, parent).doc(item.id);
if (await _checkConnectivity()) {
await ref.set(data);
} else {
ref.set(data);
}
return ref;
}