Browse Source

refactor: add meta type in metaDiff response

Signed-off-by: Pranav C <pranavxc@gmail.com>
pull/894/head
Pranav C 3 years ago
parent
commit
26d5362599
  1. 11
      packages/nocodb/src/lib/noco/meta/handlers/xcMetaDiff.ts

11
packages/nocodb/src/lib/noco/meta/handlers/xcMetaDiff.ts

@ -18,6 +18,11 @@ enum XcMetaDiffType {
TABLE_VIRTUAL_M2M_REMOVE = 'TABLE_VIRTUAL_M2M_REMOVE' TABLE_VIRTUAL_M2M_REMOVE = 'TABLE_VIRTUAL_M2M_REMOVE'
} }
enum XcMetaType {
TABLE = 'table',
VIEW = 'view'
}
interface NcMetaDiff { interface NcMetaDiff {
tn: string; tn: string;
detectedChanges: Array<{ detectedChanges: Array<{
@ -72,6 +77,7 @@ export default async function(
if (oldMetaIdx === -1) { if (oldMetaIdx === -1) {
changes.push({ changes.push({
tn: table.tn, tn: table.tn,
type: XcMetaType.TABLE,
detectedChanges: [ detectedChanges: [
{ {
type: XcMetaDiffType.TABLE_NEW, type: XcMetaDiffType.TABLE_NEW,
@ -87,6 +93,7 @@ export default async function(
const tableProp = { const tableProp = {
tn: table.tn, tn: table.tn,
type: XcMetaType.TABLE,
detectedChanges: [] detectedChanges: []
}; };
changes.push(tableProp); changes.push(tableProp);
@ -185,6 +192,7 @@ export default async function(
for (const { tn } of oldMetas) { for (const { tn } of oldMetas) {
changes.push({ changes.push({
tn: tn, tn: tn,
type: XcMetaType.TABLE,
detectedChanges: [ detectedChanges: [
{ {
type: XcMetaDiffType.TABLE_REMOVE, type: XcMetaDiffType.TABLE_REMOVE,
@ -225,6 +233,7 @@ export default async function(
if (oldViewMetaIdx === -1) { if (oldViewMetaIdx === -1) {
changes.push({ changes.push({
tn: view.tn, tn: view.tn,
type: XcMetaType.VIEW,
detectedChanges: [ detectedChanges: [
{ {
type: XcMetaDiffType.VIEW_NEW, type: XcMetaDiffType.VIEW_NEW,
@ -240,6 +249,7 @@ export default async function(
const viewProp = { const viewProp = {
tn: view.tn, tn: view.tn,
type: XcMetaType.VIEW,
detectedChanges: [] detectedChanges: []
}; };
changes.push(viewProp); changes.push(viewProp);
@ -338,6 +348,7 @@ export default async function(
for (const { tn } of oldViewMetas) { for (const { tn } of oldViewMetas) {
changes.push({ changes.push({
tn: tn, tn: tn,
type: XcMetaType.VIEW,
detectedChanges: [ detectedChanges: [
{ {
type: XcMetaDiffType.VIEW_REMOVE, type: XcMetaDiffType.VIEW_REMOVE,

Loading…
Cancel
Save