wip fix batch update
This commit is contained in:
parent
5ab4e55357
commit
b7f4fd84e3
|
|
@ -1,11 +1,10 @@
|
||||||
|
import { dir } from "dir";
|
||||||
import { dirAsync } from "fs-jetpack";
|
import { dirAsync } from "fs-jetpack";
|
||||||
import trim from "lodash.trim";
|
import trim from "lodash.trim";
|
||||||
import { dirname } from "path";
|
import { dirname } from "path";
|
||||||
import { apiContext } from "../../../pkgs/core/server/api/api-ctx";
|
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 { prismaExtendType } from "../../web/src/utils/script/prisma-extend";
|
||||||
|
import { baseTypings } from "../../web/src/utils/script/types/base";
|
||||||
|
|
||||||
export const _ = {
|
export const _ = {
|
||||||
url: "/code/:site_id/:action",
|
url: "/code/:site_id/:action",
|
||||||
|
|
|
||||||
File diff suppressed because one or more lines are too long
|
|
@ -7,6 +7,21 @@ export const dbProxy = (dburl: string) => {
|
||||||
{},
|
{},
|
||||||
{
|
{
|
||||||
get(_, table: 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") {
|
if (table === "_schema") {
|
||||||
return {
|
return {
|
||||||
tables: async () => {
|
tables: async () => {
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,11 @@
|
||||||
export const prismaExtendType = `\
|
export const prismaExtendType = `\
|
||||||
{
|
{
|
||||||
|
_batch: {
|
||||||
|
update: (
|
||||||
|
table: string,
|
||||||
|
batch: { data: any, where: any }[]
|
||||||
|
) => Promise<void>;
|
||||||
|
};
|
||||||
_schema: {
|
_schema: {
|
||||||
tables: () => Promise<string[]>;
|
tables: () => Promise<string[]>;
|
||||||
columns: (table: string) => Promise<
|
columns: (table: string) => Promise<
|
||||||
|
|
@ -26,9 +32,9 @@ export const prismaExtendType = `\
|
||||||
}
|
}
|
||||||
}>;
|
}>;
|
||||||
}
|
}
|
||||||
}`
|
}`;
|
||||||
|
|
||||||
const rel_types = `\
|
const rel_types = `\
|
||||||
{
|
{
|
||||||
|
|
||||||
}`
|
}`;
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue