Files
cgm-remote-monitor/testing/populate.js
T
Adam HarrisonandGitHub b1ec21cd3f 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.
2020-02-05 08:27:56 +02:00

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);
});
}