wip fix
This commit is contained in:
parent
9ea7e373d8
commit
90678d1fae
|
|
@ -1,15 +1,16 @@
|
||||||
import { apiContext } from "service-srv";
|
import { apiContext } from "service-srv";
|
||||||
import { execQuery } from "utils/query";
|
import { execQuery } from "utils/query";
|
||||||
|
|
||||||
|
const g = global as any;
|
||||||
export const _ = {
|
export const _ = {
|
||||||
url: "/_dbs/:dbName/:action",
|
url: "/_dbs/:tableName",
|
||||||
async api(dbName: any, action?: string) {
|
async api(tableName: any) {
|
||||||
const { req, res } = apiContext(this);
|
const { req, res } = apiContext(this);
|
||||||
if (typeof db !== "undefined") {
|
if (typeof g.db !== "undefined") {
|
||||||
const body = req.params;
|
const body = req.params;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const result = await execQuery(body, db);
|
const result = await execQuery(body, g.db);
|
||||||
res.send(result);
|
res.send(result);
|
||||||
} catch (e: any) {
|
} catch (e: any) {
|
||||||
res.sendStatus(500);
|
res.sendStatus(500);
|
||||||
|
|
|
||||||
|
|
@ -10,6 +10,8 @@ export type DBArg = {
|
||||||
export const execQuery = async (args: DBArg, prisma: any) => {
|
export const execQuery = async (args: DBArg, prisma: any) => {
|
||||||
const { table, action, params } = args;
|
const { table, action, params } = args;
|
||||||
|
|
||||||
|
console.log(args);
|
||||||
|
|
||||||
const tableInstance = prisma[table];
|
const tableInstance = prisma[table];
|
||||||
|
|
||||||
if (tableInstance) {
|
if (tableInstance) {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue