mirror of
https://github.com/nocodb/nocodb.git
synced 2026-02-02 01:17:58 +00:00
- Rename `Project` => `Base` - Rename `Base` => `Source` - Remove `db` from data/meta api endpoints - Add backward compatibility for old apis - Migrations for renaming table and columns Signed-off-by: Pranav C <pranavxc@gmail.com>
66 lines
1.4 KiB
TypeScript
66 lines
1.4 KiB
TypeScript
import { Api } from 'nocodb-sdk';
|
|
import { NcContext } from './index';
|
|
import { isEE } from './db';
|
|
let api: Api<any>;
|
|
|
|
async function createXcdb(context: NcContext) {
|
|
api = new Api({
|
|
baseURL: `http://localhost:8080/`,
|
|
headers: {
|
|
'xc-auth': context.token,
|
|
},
|
|
});
|
|
|
|
let baseList;
|
|
|
|
if (isEE() && context.workspace?.id) {
|
|
baseList = await api['workspaceBase'].list(context.workspace.id);
|
|
} else {
|
|
baseList = await api.base.list();
|
|
}
|
|
|
|
for (const base of baseList.list) {
|
|
// delete base with title 'xcdb' if it exists
|
|
if (base.title === 'xcdb') {
|
|
await api.base.delete(base.id);
|
|
}
|
|
}
|
|
|
|
const base = await api.base.create({
|
|
title: 'xcdb',
|
|
type: 'database',
|
|
...(isEE()
|
|
? {
|
|
fk_workspace_id: context?.workspace?.id,
|
|
}
|
|
: {}),
|
|
});
|
|
return base;
|
|
}
|
|
|
|
async function deleteXcdb(context: NcContext) {
|
|
api = new Api({
|
|
baseURL: `http://localhost:8080/`,
|
|
headers: {
|
|
'xc-auth': context.token,
|
|
},
|
|
});
|
|
|
|
let baseList;
|
|
|
|
if (isEE() && context.workspace?.id) {
|
|
baseList = await api['workspaceBase'].list(context.workspace.id);
|
|
} else {
|
|
baseList = await api.base.list();
|
|
}
|
|
|
|
for (const base of baseList.list) {
|
|
// delete base with title 'xcdb' if it exists
|
|
if (base.title === 'xcdb') {
|
|
await api.base.delete(base.id);
|
|
}
|
|
}
|
|
}
|
|
|
|
export { createXcdb, deleteXcdb };
|