UNPKG

615 BJavaScriptView Raw
1'use strict';
2
3const Server = require('mongodb-topology-manager').Server;
4const co = require('co');
5const mongodb = require('mongodb');
6
7co(function*() {
8 // Create new instance
9 var server = new Server('mongod', {
10 auth: null,
11 dbpath: '/data/db/27017'
12 });
13
14 // Purge the directory
15 yield server.purge();
16
17 // Start process
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});