update table schema doc path

This commit is contained in:
Sidney Alcantara
2021-09-01 20:33:37 +10:00
parent 1593411646
commit 830605a050
3 changed files with 4 additions and 6 deletions

View File

@@ -122,7 +122,7 @@ export default function TableSettingsDialog({
};
const handleResetStructure = async () => {
const schemaDocRef = db.doc(`_rowy_/settings/schema/${data!.collection}`);
const schemaDocRef = db.doc(`_rowy_/settings/table/${data!.collection}`);
await schemaDocRef.update({ columns: {} });
handleClose();
};

View File

@@ -24,9 +24,7 @@ export default function Settings({ handleChange, config }: ISettingsProps) {
{ value: string; label: string; type: FieldType }[]
>([]);
const getColumns = async (table) => {
const tableConfigDoc = await db
.doc(`_rowy_/settings/schema/${table}`)
.get();
const tableConfigDoc = await db.doc(`_rowy_/settings/table/${table}`).get();
const tableConfig = tableConfigDoc.data();
if (tableConfig && tableConfig.columns)
setColumns(

View File

@@ -80,7 +80,7 @@ const useSettings = () => {
),
//update the rowy collection doc with empty columns
db
.collection("_rowy_/settings/schema")
.collection("_rowy_/settings/table")
.doc(data.collection)
.set({ ...data }, { merge: true }),
]);
@@ -91,7 +91,7 @@ const useSettings = () => {
db.doc("_rowy_/settings").update({
tables: tables.filter((table) => table.collection !== collection),
});
db.collection("_rowy_/settings/schema").doc(collection).delete();
db.collection("_rowy_/settings/table").doc(collection).delete();
};
const settingsActions = { createTable, updateTable, deleteTable };
return [settingsState, settingsActions];