documentFromObject method

DocumentReference<Map<String, dynamic>> documentFromObject(
  1. dynamic object, {
  2. String? subcollection,
})

Returns a reference to a document using an object.

Implementation

DocumentReference<Map<String, dynamic>> documentFromObject(dynamic object, { String? subcollection }) {
  if (object == null) {
    throw NullIDException("Cannot get document reference from null object");
  }
  if (subcollection != null) {
    return FS.instance.collection(object.runtimeType.toString()).doc(subcollection).collection(subcollection).doc(object.id);
  }
  return FS.instance.collection(object.runtimeType.toString()).doc(object.id);
}