wip fix batch update

This commit is contained in:
Rizky 2024-03-13 15:05:05 +07:00
parent 5ab4e55357
commit b7f4fd84e3
4 changed files with 42 additions and 22 deletions

View File

@ -1,11 +1,10 @@
import { dir } from "dir";
import { dirAsync } from "fs-jetpack";
import trim from "lodash.trim";
import { dirname } from "path";
import { apiContext } from "../../../pkgs/core/server/api/api-ctx";
import { g } from "utils/global";
import { baseTypings } from "../../web/src/utils/script/types/base";
import { dir } from "dir";
import { prismaExtendType } from "../../web/src/utils/script/prisma-extend";
import { baseTypings } from "../../web/src/utils/script/types/base";
export const _ = {
url: "/code/:site_id/:action",

File diff suppressed because one or more lines are too long

View File

@ -7,6 +7,21 @@ export const dbProxy = (dburl: string) => {
{},
{
get(_, table: string) {
if (table === "_batch") {
return {
update: async (table: string, batch: any) => {
return fetchSendDb(
{
name,
action: "batch_update",
table: "",
params: { table, batch },
},
dburl
);
},
};
}
if (table === "_schema") {
return {
tables: async () => {

View File

@ -1,5 +1,11 @@
export const prismaExtendType = `\
{
_batch: {
update: (
table: string,
batch: { data: any, where: any }[]
) => Promise<void>;
};
_schema: {
tables: () => Promise<string[]>;
columns: (table: string) => Promise<
@ -26,9 +32,9 @@ export const prismaExtendType = `\
}
}>;
}
}`
}`;
const rel_types = `\
{
}`
}`;