addWithId method
Implementation
@override
Future<T> addWithId(String id, T item) async {
try {
final document = _toFirestore(item, id);
document.name = null;
final parent =
collectionParentPath.isEmpty
? documentsPath
: '$documentsPath/$collectionParentPath';
final createdDocument = await _firestore.projects.databases.documents
.createDocument(document, parent, collectionId, documentId: id);
return _fromFirestore(createdDocument);
} catch (e) {
if (e is DetailedApiRequestError && e.status == 409) {
throw RepositoryException.alreadyExists(id);
}
rethrow;
}
}