Browse Source

refactor: nc_minimal_dbs auto generated name

Signed-off-by: mertmit <mertmit99@gmail.com>
pull/4137/head
mertmit 2 years ago
parent
commit
4c45899f3f
  1. 3
      packages/nocodb/src/lib/Noco.ts
  2. 4
      packages/nocodb/src/lib/meta/api/projectApis.ts

3
packages/nocodb/src/lib/Noco.ts

@ -103,11 +103,12 @@ export default class Noco {
// todo: move
process.env.NC_VERSION = '0090000';
// if env variable NC_MINIMAL_DBS is set, then disable project creation with external sources
if (process.env.NC_MINIMAL_DBS) {
process.env.NC_CONNECT_TO_EXTERNAL_DB_DISABLED = 'true';
}
this.router = express.Router();
this.router = express.Router();s
this.projectRouter = express.Router();
/* prepare config */

4
packages/nocodb/src/lib/meta/api/projectApis.ts

@ -109,6 +109,8 @@ async function projectCreate(req: Request<any, any>, res) {
projectBody.prefix = `nc_${ranId}__`;
projectBody.is_meta = true;
if (process.env.NC_MINIMAL_DBS) {
// if env variable NC_MINIMAL_DBS is set, then create a SQLite file/connection for each project
// each file will be named as nc_<random_id>.db
const fs = require('fs');
const toolDir = NcConfigFactory.getToolDir();
const nanoidv2 = customAlphabet('1234567890abcdefghijklmnopqrstuvwxyz', 14);
@ -127,7 +129,7 @@ async function projectCreate(req: Request<any, any>, res) {
client: "sqlite3",
database: projectTitle,
connection: {
filename: `${toolDir}/nc_minimal_dbs/${projectTitle}_${dbId}.sql`,
filename: `${toolDir}/nc_minimal_dbs/${projectTitle}_${dbId}.db`,
},
useNullAsDefault: true,
},

Loading…
Cancel
Save