fix
This commit is contained in:
parent
073a8cc557
commit
722b8ccea8
|
|
@ -2,6 +2,12 @@ import hash_sum from "hash-sum";
|
||||||
import pako from "pako";
|
import pako from "pako";
|
||||||
import { fetchViaProxy } from "../proxy";
|
import { fetchViaProxy } from "../proxy";
|
||||||
|
|
||||||
|
const schema_promise = {
|
||||||
|
tables: {} as Record<string, any>,
|
||||||
|
columns: {} as Record<string, any>,
|
||||||
|
rels: {} as Record<string, any>,
|
||||||
|
}
|
||||||
|
|
||||||
export const dbProxy = (dburl: string) => {
|
export const dbProxy = (dburl: string) => {
|
||||||
const name = "";
|
const name = "";
|
||||||
return new Proxy(
|
return new Proxy(
|
||||||
|
|
@ -37,37 +43,49 @@ export const dbProxy = (dburl: string) => {
|
||||||
if (table === "_schema") {
|
if (table === "_schema") {
|
||||||
return {
|
return {
|
||||||
tables: async () => {
|
tables: async () => {
|
||||||
return fetchSendDb(
|
if (!schema_promise.tables[dburl]) {
|
||||||
{
|
schema_promise.tables[dburl] = fetchSendDb(
|
||||||
name,
|
{
|
||||||
action: "schema_tables",
|
name,
|
||||||
table: "",
|
action: "schema_tables",
|
||||||
params: [],
|
table: "",
|
||||||
},
|
params: [],
|
||||||
dburl
|
},
|
||||||
);
|
dburl
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
return await schema_promise.tables[dburl]
|
||||||
},
|
},
|
||||||
columns: async (table: string) => {
|
columns: async (table: string) => {
|
||||||
return fetchSendDb(
|
if (!schema_promise.columns[dburl + '_' + table]) {
|
||||||
{
|
schema_promise.columns[dburl + '_' + table] = fetchSendDb(
|
||||||
name,
|
{
|
||||||
action: "schema_columns",
|
name,
|
||||||
table,
|
action: "schema_columns",
|
||||||
params: [],
|
table,
|
||||||
},
|
params: [],
|
||||||
dburl
|
},
|
||||||
);
|
dburl
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
return await schema_promise.columns[dburl + '_' + table]
|
||||||
},
|
},
|
||||||
rels: async (table: string) => {
|
rels: async (table: string) => {
|
||||||
return fetchSendDb(
|
if (!schema_promise.rels[dburl + '_' + table]) {
|
||||||
{
|
schema_promise.rels[dburl + '_' + table] = fetchSendDb(
|
||||||
name,
|
{
|
||||||
action: "schema_rels",
|
name,
|
||||||
table,
|
action: "schema_rels",
|
||||||
params: [],
|
table,
|
||||||
},
|
params: [],
|
||||||
dburl
|
},
|
||||||
);
|
dburl
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
return await schema_promise.rels[dburl + '_' + table]
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
@ -156,5 +174,5 @@ export const fetchSendDb = async (params: any, dburl: string) => {
|
||||||
}
|
}
|
||||||
|
|
||||||
return await cached.promise;
|
return await cached.promise;
|
||||||
} catch (e) {}
|
} catch (e) { }
|
||||||
};
|
};
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue