summaryrefslogtreecommitdiffstats
path: root/node_modules/mongoose/tools/auth.js
blob: 7cfaf86c16ace3ba4086c2bd084b3aeab4e830b6 (plain) (blame)
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
'use strict';

const Server = require('mongodb-topology-manager').Server;
const co = require('co');
const mongodb = require('mongodb');

co(function*() {
  // Create new instance
  const server = new Server('mongod', {
    auth: null,
    dbpath: '/data/db/27017'
  });

  // Purge the directory
  yield server.purge();

  // Start process
  yield server.start();

  const db = yield mongodb.MongoClient.connect('mongodb://localhost:27017/admin');

  yield db.addUser('passwordIsTaco', 'taco', {
    roles: ['dbOwner']
  });

  console.log('done');
}).catch(error => {
  console.error(error);
  process.exit(-1);
});