mirror of
https://github.com/DeNNiiInc/dbgate.git
synced 2026-04-18 04:26:01 +00:00
SYNC: mongo import tests
This commit is contained in:
committed by
Diflow
parent
0046575a4f
commit
2b7f4281c2
@@ -8,12 +8,13 @@ dbgateApi.registerPlugins(dbgatePluginMysql);
|
||||
const dbgatePluginPostgres = require('dbgate-plugin-postgres');
|
||||
dbgateApi.registerPlugins(dbgatePluginPostgres);
|
||||
|
||||
async function createDb(connection, dropDbSql, createDbSql, database = 'my_guitar_shop') {
|
||||
async function createDb(connection, dropDbSql, createDbSql, database = 'my_guitar_shop', { dropDatabaseName }) {
|
||||
if (dropDbSql) {
|
||||
try {
|
||||
await dbgateApi.executeQuery({
|
||||
connection,
|
||||
sql: dropDbSql,
|
||||
database: dropDatabaseName,
|
||||
});
|
||||
} catch (err) {
|
||||
console.error('Failed to drop database', err);
|
||||
@@ -108,6 +109,22 @@ async function run() {
|
||||
null
|
||||
);
|
||||
}
|
||||
|
||||
if (localconfig.mongo) {
|
||||
await createDb(
|
||||
{
|
||||
server: process.env.SERVER_mongo,
|
||||
user: process.env.USER_mongo,
|
||||
password: process.env.PASSWORD_mongo,
|
||||
port: process.env.PORT_mongo,
|
||||
engine: 'mongo@dbgate-plugin-mongo',
|
||||
},
|
||||
'db.dropDatabase()',
|
||||
null,
|
||||
'my_guitar_shop',
|
||||
{ dropDatabaseName: 'my_guitar_shop' }
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
dbgateApi.runScript(run);
|
||||
|
||||
Reference in New Issue
Block a user