-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathreset.js
More file actions
31 lines (28 loc) · 995 Bytes
/
Copy pathreset.js
File metadata and controls
31 lines (28 loc) · 995 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
// setup.js
const mongoClient = require('mongodb').MongoClient;
// const Db = require('mongodb').Db;
const asyncmodule = require('async');
const assert = require('assert');
mongoClient.connect('mongodb://localhost:27017/test', function (err, db) {
assert.equal(null, err);
var db1 = db.db('edx');
//
// May be a better way to do this:
//
// This checks to see if
// at least one of the collections exist before continuing.
db1.listCollections({name: 'customers'})
.next(function (err, collinfo) {
if (collinfo) {
console.log('Cleaning up...');
db1.dropCollection("customers", function(err, result) {
assert.equal(null, err);
db1.close();
});
}
else {
console.log('Good to go. No cleanup needed apparently.');
db1.close();
}
});
});