set method
Future<InAppDocumentSnapshot?>
set(
- InAppDocument data, [
- InAppSetOptions options = const InAppSetOptions()
Method to set data in the document.
Parameters:
data
: The data to be set in the document.
Example:
documentRef.set({'name': 'John', 'age': 30});
Implementation
Future<InAppDocumentSnapshot?> set(
InAppDocument data, [
InAppSetOptions options = const InAppSetOptions(),
]) {
final i = data[_idField];
final mId = i is String ? i : id;
data[_idField] = mId;
if (options.merge) {
return update(data);
} else {
return _db
._w(
reference: reference,
collectionPath: _p.path,
collectionId: _p.id,
documentId: mId,
type: InAppWriteType.document,
value: data,
)
.then(_n)
.then((_) => _ ? InAppDocumentSnapshot(mId, data) : null);
}
}