mirror of
https://github.com/Ylianst/MeshCentral.git
synced 2025-02-15 04:21:51 +00:00
MongoDB TextEncoder is not defined fix (#4499)
This commit is contained in:
parent
77405a7232
commit
43abf32dba
1 changed files with 9 additions and 4 deletions
5
db.js
5
db.js
|
@ -828,6 +828,11 @@ module.exports.CreateDB = function (parent, func) {
|
||||||
} else if (parent.args.mongodb) {
|
} else if (parent.args.mongodb) {
|
||||||
// Use MongoDB
|
// Use MongoDB
|
||||||
obj.databaseType = 3;
|
obj.databaseType = 3;
|
||||||
|
|
||||||
|
// If running an older NodeJS version, TextEncoder/TextDecoder is required
|
||||||
|
if (global.TextEncoder == null) { global.TextEncoder = require('util').TextEncoder; }
|
||||||
|
if (global.TextDecoder == null) { global.TextDecoder = require('util').TextDecoder; }
|
||||||
|
|
||||||
require('mongodb').MongoClient.connect(parent.args.mongodb, { useNewUrlParser: true, useUnifiedTopology: true }, function (err, client) {
|
require('mongodb').MongoClient.connect(parent.args.mongodb, { useNewUrlParser: true, useUnifiedTopology: true }, function (err, client) {
|
||||||
if (err != null) { console.log("Unable to connect to database: " + err); process.exit(); return; }
|
if (err != null) { console.log("Unable to connect to database: " + err); process.exit(); return; }
|
||||||
Datastore = client;
|
Datastore = client;
|
||||||
|
|
Loading…
Reference in a new issue