mirror of
https://github.com/DeNNiiInc/dbgate.git
synced 2026-04-18 18:26:00 +00:00
Connection to MognoDB legacy
This commit is contained in:
@@ -16,9 +16,12 @@ function jsonStringifyWithObjectId(obj) {
|
||||
return JSON.stringify(obj, mongoReplacer, 2)
|
||||
.replace(/\{\s*\"\$oid\"\s*\:\s*\"([0-9a-f]+)\"\s*\}/g, (m, id) => `ObjectId("${id}")`)
|
||||
.replace(/\{\s*\"\$bigint\"\s*\:\s*\"([0-9]+)\"\s*\}/g, (m, num) => `${num}n`)
|
||||
.replace(/\{\s*"\$binary"\s*:\s*\{\s*"base64"\s*:\s*"([^"]+)"(?:\s*,\s*"subType"\s*:\s*"([0-9a-fA-F]{2})")?\s*\}\s*\}/g, (m, base64, subType) => {
|
||||
return `BinData(${parseInt(subType || "00", 16)}, "${base64}")`;
|
||||
});
|
||||
.replace(
|
||||
/\{\s*"\$binary"\s*:\s*\{\s*"base64"\s*:\s*"([^"]+)"(?:\s*,\s*"subType"\s*:\s*"([0-9a-fA-F]{2})")?\s*\}\s*\}/g,
|
||||
(m, base64, subType) => {
|
||||
return `BinData(${parseInt(subType || '00', 16)}, "${base64}")`;
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
/** @type {import('dbgate-types').SqlDialect} */
|
||||
@@ -34,7 +37,7 @@ const dialect = {
|
||||
};
|
||||
|
||||
/** @type {import('dbgate-types').EngineDriver} */
|
||||
const driver = {
|
||||
const mongoDriverBase = {
|
||||
...driverBase,
|
||||
dumperClass: Dumper,
|
||||
databaseEngineTypes: ['document'],
|
||||
@@ -193,4 +196,16 @@ const driver = {
|
||||
},
|
||||
};
|
||||
|
||||
module.exports = driver;
|
||||
const mongoDriver = {
|
||||
...mongoDriverBase,
|
||||
};
|
||||
|
||||
const legacyMongoDriver = {
|
||||
...mongoDriverBase,
|
||||
engine: 'mongo-legacy@dbgate-plugin-mongo',
|
||||
title: 'MongoDB 4 - Legacy',
|
||||
premiumOnly: true,
|
||||
useLegacyDriver: true,
|
||||
};
|
||||
|
||||
module.exports = [mongoDriver, legacyMongoDriver];
|
||||
@@ -1,9 +1,9 @@
|
||||
import driver from './driver';
|
||||
import drivers from './drivers';
|
||||
import { formatProfilerEntry, extractProfileTimestamp, aggregateProfileChartEntry } from './profilerFunctions';
|
||||
|
||||
export default {
|
||||
packageName: 'dbgate-plugin-mongo',
|
||||
drivers: [driver],
|
||||
drivers,
|
||||
functions: {
|
||||
formatProfilerEntry,
|
||||
extractProfileTimestamp,
|
||||
|
||||
Reference in New Issue
Block a user