Ohm-Management - Projektarbeit B-ME
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

auth.js 615B

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