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.

native_topology.js 1.6KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. 'use strict';
  2. const Topology = require('mongodb-core').Topology;
  3. const ServerCapabilities = require('./topology_base').ServerCapabilities;
  4. const Cursor = require('../cursor');
  5. const translateOptions = require('../utils').translateOptions;
  6. class NativeTopology extends Topology {
  7. constructor(servers, options) {
  8. options = options || {};
  9. let clonedOptions = Object.assign(
  10. {},
  11. {
  12. cursorFactory: Cursor,
  13. reconnect: false,
  14. emitError: typeof options.emitError === 'boolean' ? options.emitError : true,
  15. size: typeof options.poolSize === 'number' ? options.poolSize : 5,
  16. monitorCommands:
  17. typeof options.monitorCommands === 'boolean' ? options.monitorCommands : false
  18. }
  19. );
  20. // Translate any SSL options and other connectivity options
  21. clonedOptions = translateOptions(clonedOptions, options);
  22. // Socket options
  23. var socketOptions =
  24. options.socketOptions && Object.keys(options.socketOptions).length > 0
  25. ? options.socketOptions
  26. : options;
  27. // Translate all the options to the mongodb-core ones
  28. clonedOptions = translateOptions(clonedOptions, socketOptions);
  29. super(servers, clonedOptions);
  30. // Do we have an application specific string
  31. if (options.appname) {
  32. this.s.clientInfo.application = { name: options.appname };
  33. }
  34. }
  35. capabilities() {
  36. if (this.s.sCapabilities) return this.s.sCapabilities;
  37. if (this.lastIsMaster() == null) return null;
  38. this.s.sCapabilities = new ServerCapabilities(this.lastIsMaster());
  39. return this.s.sCapabilities;
  40. }
  41. }
  42. module.exports = NativeTopology;