show error when table has no collection set (#857, #858)

This commit is contained in:
Sidney Alcantara
2022-10-12 10:47:52 +11:00
parent a24f2bd227
commit a2dacd9f98

View File

@@ -32,7 +32,11 @@ import { getTableSchemaPath } from "@src/utils/table";
export const TableSourceFirestore = memo(function TableSourceFirestore() {
// Get tableSettings from tableId and tables in projectScope
const [tableSettings] = useAtom(tableSettingsAtom, tableScope);
const isCollectionGroup = tableSettings?.tableType === "collectionGroup";
if (!tableSettings) throw new Error("No table config");
if (!tableSettings.collection)
throw new Error("Invalid table config: no collection");
const isCollectionGroup = tableSettings.tableType === "collectionGroup";
// Get tableSchema and store in tableSchemaAtom.
// If it doesnt exist, initialize columns
@@ -63,7 +67,7 @@ export const TableSourceFirestore = memo(function TableSourceFirestore() {
useFirestoreCollectionWithAtom(
tableRowsDbAtom,
tableScope,
tableSettings?.collection,
tableSettings.collection,
{
filters,
sorts,