fix
This commit is contained in:
parent
3d0c77f41f
commit
631f69e6fc
|
|
@ -1,3 +1,5 @@
|
||||||
|
import { Prisma } from "../../../app/db/db";
|
||||||
|
import { gunzipAsync } from "./diff/diff";
|
||||||
|
|
||||||
export type DBArg = {
|
export type DBArg = {
|
||||||
db: string;
|
db: string;
|
||||||
|
|
@ -14,10 +16,20 @@ export const execQuery = async (args: DBArg, prisma: any) => {
|
||||||
if (tableInstance) {
|
if (tableInstance) {
|
||||||
if (action === "query" && table.startsWith("$query")) {
|
if (action === "query" && table.startsWith("$query")) {
|
||||||
try {
|
try {
|
||||||
const q = params.shift();
|
const gzip = params as unknown as string;
|
||||||
q.sql = true;
|
|
||||||
Object.freeze(q);
|
if (typeof gzip === "string") {
|
||||||
return await tableInstance.bind(prisma)(q, ...params);
|
const u8 = new Uint8Array(
|
||||||
|
[...atob(gzip)].map((c) => c.charCodeAt(0))
|
||||||
|
);
|
||||||
|
const json = JSON.parse((await gunzipAsync(u8)).toString("utf8"));
|
||||||
|
|
||||||
|
if (Array.isArray(json)) {
|
||||||
|
const q = json.shift();
|
||||||
|
return await tableInstance.bind(prisma)(Prisma.sql(q, ...json));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
console.log(e);
|
console.log(e);
|
||||||
return e;
|
return e;
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue