UNPKG

602 BJavaScriptView Raw
1'use strict';
2
3const Server = require('mongodb-topology-manager').Server;
4const mongodb = require('mongodb');
5
6run().catch(error => {
7 console.error(error);
8 process.exit(-1);
9});
10
11async function run() {
12 // Create new instance
13 const server = new Server('mongod', {
14 auth: null,
15 dbpath: '/data/db/27017'
16 });
17
18 // Purge the directory
19 await server.purge();
20
21 // Start process
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