one method

Future<void> one(
  1. dynamic object, {
  2. String? subcollection,
})

Creates a document in Firestore from the given object.

Implementation

Future<void> one(dynamic object, { String? subcollection }) async {
  final serializer = RDB.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);
  }

  final reference = RDB.instance.ref(RDB.constructPathForClassAndID(object.runtimeType, object.id));
  return reference.set(map);
}