Upgrade Mongo driver to latest legacy-API compatible version

This commit is contained in:
Sulka Haro
2023-06-01 12:20:36 +03:00
parent cf5646bb7a
commit 93ffb25147
13 changed files with 13842 additions and 213 deletions
+1 -1
View File
@@ -2,7 +2,7 @@
const _ = require('lodash')
, checkForHexRegExp = new RegExp("^[0-9a-fA-F]{24}$")
, ObjectID = require('mongodb').ObjectID
, ObjectID = require('mongodb-legacy').ObjectID
;
+11 -2
View File
@@ -3,7 +3,7 @@
var _ = require('lodash');
var crypto = require('crypto');
var shiroTrie = require('shiro-trie');
var ObjectID = require('mongodb').ObjectID;
var ObjectID = require('mongodb-legacy').ObjectID;
var find_options = require('../server/query');
@@ -42,7 +42,7 @@ function init (env, ctx) {
}
function list (collection) {
function doList(opts, fn) {
function doList(opts, fn) {
// these functions, find, sort, and limit, are used to
// dynamically configure the request, based on the options we've
// been given
@@ -65,6 +65,8 @@ function init (env, ctx) {
fn(err, entries);
}
console.log('Loading',opts);
// now just stitch them all together
limit.call(collection
.find(query_for(opts))
@@ -135,8 +137,14 @@ function init (env, ctx) {
storage.reload = function reload (callback) {
console.log('Reloading auth data');
storage.listRoles({sort: {name: 1}}, function listResults (err, results) {
console.log('Roles listed');
if (err) {
console.log('Problem listing roles', err);
return callback && callback(err);
}
@@ -152,6 +160,7 @@ function init (env, ctx) {
storage.listSubjects({sort: {name: 1}}, function listResults (err, results) {
if (err) {
console.log('Problem listing subjects', err);
return callback && callback(err);
}
+1 -1
View File
@@ -4,7 +4,7 @@ var find_options = require('./query');
function storage (env, ctx) {
var ObjectID = require('mongodb').ObjectID;
var ObjectID = require('mongodb-legacy').ObjectID;
function create (obj, fn) {
obj.created_at = (new Date( )).toISOString( );
+3 -1
View File
@@ -7,7 +7,9 @@ function boot (env, language) {
function startBoot(ctx, next) {
console.log('Executing startBoot');
console.log('++++++++++++++++++++++++++++++');
console.log('Nightscout Executing startBoot');
console.log('++++++++++++++++++++++++++++++');
ctx.moment = require('moment-timezone');
ctx.runtimeState = 'booting';
+1 -1
View File
@@ -2,7 +2,7 @@
var es = require('event-stream');
var find_options = require('./query');
var ObjectID = require('mongodb').ObjectID;
var ObjectID = require('mongodb-legacy').ObjectID;
var moment = require('moment');
/**********\
+1 -1
View File
@@ -1,7 +1,7 @@
'use strict';
function storage (env, ctx) {
var ObjectID = require('mongodb').ObjectID;
var ObjectID = require('mongodb-legacy').ObjectID;
function create (obj, fn) {
obj.created_at = (new Date( )).toISOString( );
+1 -1
View File
@@ -4,7 +4,7 @@ var find_options = require('./query');
var consts = require('../constants');
function storage (collection, ctx) {
var ObjectID = require('mongodb').ObjectID;
var ObjectID = require('mongodb-legacy').ObjectID;
function create (obj, fn) {
obj.created_at = (new Date( )).toISOString( );
+1 -1
View File
@@ -1,7 +1,7 @@
'use strict';
const traverse = require('traverse');
const ObjectID = require('mongodb').ObjectID;
const ObjectID = require('mongodb-legacy').ObjectID;
const moment = require('moment');
const TWO_DAYS = 172800000;
+1 -1
View File
@@ -6,7 +6,7 @@ var moment = require('moment');
var find_options = require('./query');
function storage (env, ctx) {
var ObjectID = require('mongodb').ObjectID;
var ObjectID = require('mongodb-legacy').ObjectID;
function create (objOrArray, fn) {
+1 -1
View File
@@ -2,7 +2,7 @@
var times = require('../times');
var calcData = require('../data/calcdelta');
var ObjectID = require('mongodb').ObjectID;
var ObjectID = require('mongodb-legacy').ObjectID;
const forwarded = require('forwarded-for');
function getRemoteIP (req) {
+4 -3
View File
@@ -1,6 +1,6 @@
'use strict';
const MongoClient = require('mongodb').MongoClient;
const MongoClient = require('mongodb-legacy').MongoClient;
const mongo = {
client: null,
@@ -82,10 +82,11 @@ function init(env, cb, forceNewConnection) {
mongo.ensureIndexes = function ensureIndexes(collection, fields) {
fields.forEach(function (field) {
console.info('ensuring index for: ' + field);
const name = collection.collectionName + "." + field;
console.info('ensuring index for: ' + name);
collection.createIndex(field, { 'background': true }, function (err) {
if (err) {
console.error('unable to ensureIndex for: ' + field + ' - ' + err);
console.error('unable to ensureIndex for: ' + name + ' - ' + err);
}
});
});
+13815 -198
View File
File diff suppressed because it is too large Load Diff
+1 -1
View File
@@ -115,7 +115,7 @@
"moment-timezone": "^0.5.31",
"moment-timezone-data-webpack-plugin": "^1.5.0",
"mongo-url-parser": "^1.0.2",
"mongodb": "^3.6.0",
"mongodb-legacy": "^5.0.0",
"mongomock": "^0.1.2",
"node-cache": "^4.2.1",
"parse-duration": "^0.1.3",