add method

Future<DocumentReference<T>> add(
  1. T data
)

Add a new document to this collection with the specified data, assigning it a document ID automatically.

Implementation

Future<DocumentReference<T>> add(T data) async {
  final firestoreData = _queryOptions.converter.toFirestore(data);
  _validateDocumentData(
    'data',
    firestoreData,
    allowDeletes: false,
  );

  final documentRef = doc();
  final jsonDocumentRef = documentRef.withConverter<DocumentData>(
    fromFirestore: _jsonConverter.fromFirestore,
    toFirestore: _jsonConverter.toFirestore,
  );

  return jsonDocumentRef.create(firestoreData).then((_) => documentRef);
}