-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdynamicDBService.ts
More file actions
53 lines (45 loc) · 1.41 KB
/
dynamicDBService.ts
File metadata and controls
53 lines (45 loc) · 1.41 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
import api from "@/services/api";
export interface ColumnReq {
name: string;
type: string;
}
export interface DDLTableReq {
table_name: string;
columns: ColumnReq[];
}
export const dynamicDBService = {
createTable: async (projectId: number, data: DDLTableReq) => {
const response = await api.post(`/protected/project/manage/table/create/${projectId}`, data);
return response.data;
},
addColumn: async (projectId: number, tableId: number, data: DDLTableReq) => {
const response = await api.post(`/protected/project/manage/table/create/col/${projectId}/${tableId}`, data);
return response.data;
},
getTables: async (projectId: number): Promise<DynTableDef[]> => {
const response = await api.get(`/protected/project/${projectId}/tables`);
return response.data.data;
},
deleteTable: async (projectId: number, tableId: number) => {
const response = await api.delete(`/protected/project/manage/table/drop/${projectId}/${tableId}`, {
data: {
project_id: projectId,
table_id: tableId
}
});
return response.data;
}
};
export interface DynColDef {
id: number;
dyn_table_def_id: number;
name: string;
data_type: string;
}
export interface DynTableDef {
id: number;
project_id: number;
name: string;
alias: string;
columns: DynColDef[];
}