one method
- dynamic object, {
- String? subcollection,
Creates a document in Firestore from the given object.
Implementation
Future<Transaction> one(dynamic object, { String? subcollection }) async {
final serializer = FS.serializers[object.runtimeType];
if (serializer == null) {
throw UnsupportedError('No serializer found for type: ${object.runtimeType}. Consider re-generating Firestorm data classes.');
}
final map = serializer(object);
String id = map["id"];
if (id.isEmpty) {
throw NullIDException(map);
}
DocumentReference ref = FS.instance.collection(object.runtimeType.toString()).doc(id);
if (subcollection != null) {
ref = FS.instance.collection(object.runtimeType.toString()).doc(subcollection).collection(subcollection).doc(id);
}
return _tx.set(ref, map);
}