mirror of
https://github.com/bckelley/cgm-remote-monitor.git
synced 2026-08-24 03:14:12 -05:00
* 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.
37 lines
773 B
JavaScript
37 lines
773 B
JavaScript
'use strict';
|
|
|
|
var mongodb = require('mongodb');
|
|
var env = require('./../env')();
|
|
|
|
var util = require('./util');
|
|
|
|
main();
|
|
|
|
function main() {
|
|
var MongoClient = mongodb.MongoClient;
|
|
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);
|
|
});
|
|
}
|
|
|
|
function populate_collection(db) {
|
|
var cgm_collection = db.collection(env.entries_collection);
|
|
var new_cgm_record = util.get_cgm_record();
|
|
|
|
cgm_collection.insert(new_cgm_record, function (err) {
|
|
if (err) {
|
|
throw err;
|
|
}
|
|
process.exit(0);
|
|
});
|
|
}
|