1 | 'use strict';
|
2 |
|
3 | const Server = require('mongodb-topology-manager').Server;
|
4 | const co = require('co');
|
5 | const mongodb = require('mongodb');
|
6 |
|
7 | co(function*() {
|
8 |
|
9 | var server = new Server('mongod', {
|
10 | auth: null,
|
11 | dbpath: '/data/db/27017'
|
12 | });
|
13 |
|
14 |
|
15 | yield server.purge();
|
16 |
|
17 |
|
18 | yield server.start();
|
19 |
|
20 | const db = yield mongodb.MongoClient.connect('mongodb://localhost:27017/admin');
|
21 |
|
22 | yield db.addUser('passwordIsTaco', 'taco', {
|
23 | roles: ['dbOwner']
|
24 | });
|
25 |
|
26 | console.log('done');
|
27 | }).catch(error => {
|
28 | console.error(error);
|
29 | process.exit(-1);
|
30 | });
|