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