mirror of
https://github.com/bckelley/cgm-remote-monitor.git
synced 2026-08-24 03:14:12 -05:00
Added indexes to 'entries' and 'treatments' along with other updates (#5463)
* Added compound indexes for treatments and entries collections. Updated ensureIndex to createIndex in mongo-strage.js as ensureIndex has been deprecated. Finally, updated testing/populate.js to be compatible with more recent versions of the node driver, as well as fixing a path issue. * Fixed missing end quote in lib/server/treatments.js. Changed all newly added double quotes to single quote to match style guide. * Removed indexes that referenced key600.
This commit is contained in:
@@ -140,7 +140,15 @@ function storage(env, ctx) {
|
||||
api.query_for = query_for;
|
||||
api.getEntry = getEntry;
|
||||
api.aggregate = require('./aggregate')({ }, api);
|
||||
api.indexedFields = [ 'date', 'type', 'sgv', 'mbg', 'sysTime', 'dateString' ];
|
||||
api.indexedFields = [
|
||||
'date'
|
||||
, 'type'
|
||||
, 'sgv'
|
||||
, 'mbg'
|
||||
, 'sysTime'
|
||||
, 'dateString'
|
||||
, { 'type' : 1, 'date' : -1, 'dateString' : 1 }
|
||||
];
|
||||
return api;
|
||||
}
|
||||
|
||||
@@ -160,4 +168,3 @@ storage.queryOpts = {
|
||||
// expose module
|
||||
storage.storage = storage;
|
||||
module.exports = storage;
|
||||
|
||||
|
||||
@@ -133,6 +133,7 @@ function storage (env, ctx) {
|
||||
, 'percent'
|
||||
, 'absolute'
|
||||
, 'duration'
|
||||
, { 'eventType' : 1, 'duration' : 1, 'created_at' : 1 }
|
||||
];
|
||||
|
||||
api.remove = remove;
|
||||
|
||||
@@ -66,7 +66,7 @@ function init (env, cb, forceNewConnection) {
|
||||
mongo.ensureIndexes = function ensureIndexes (collection, fields) {
|
||||
fields.forEach(function (field) {
|
||||
console.info('ensuring index for: ' + field);
|
||||
collection.ensureIndex(field, function (err) {
|
||||
collection.createIndex(field, { 'background': true }, function (err) {
|
||||
if (err) {
|
||||
console.error('unable to ensureIndex for: ' + field + ' - ' + err);
|
||||
}
|
||||
|
||||
+5
-2
@@ -3,19 +3,22 @@
|
||||
var mongodb = require('mongodb');
|
||||
var env = require('./../env')();
|
||||
|
||||
var util = require('./helpers/util');
|
||||
var util = require('./util');
|
||||
|
||||
main();
|
||||
|
||||
function main() {
|
||||
var MongoClient = mongodb.MongoClient;
|
||||
MongoClient.connect(env.storageURI, function connected(err, db) {
|
||||
MongoClient.connect(env.storageURI, { "useUnifiedTopology" : true, "useNewUrlParser" : true }, function connected(err, client) {
|
||||
|
||||
console.log('Connecting to mongo...');
|
||||
if (err) {
|
||||
console.log('Error occurred: ', err);
|
||||
throw err;
|
||||
}
|
||||
|
||||
var db = client.db();
|
||||
|
||||
populate_collection(db);
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user