Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

viewmodel

Package Overview
Dependencies
Maintainers
2
Versions
109
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

viewmodel - npm Package Compare versions

Comparing version 1.5.14 to 1.5.15

51

lib/databases/mongodb.js

@@ -48,30 +48,36 @@ 'use strict';

var server;
var connectionUrl;
if (options.servers && Array.isArray(options.servers)){
var servers = [];
if (options.url) {
connectionUrl = options.url;
} else {
var members = options.servers
? options.servers
: [{host: options.host, port: options.port}];
options.servers.forEach(function(item){
if(item.host && item.port) {
servers.push(new mongo.Server(item.host, item.port, item.options));
}
});
var memberString = _(members).map(function(m) { return m.host + ':' + m.port });
var authString = options.username && options.password
? options.username + ':' + options.password + '@'
: '';
var optionsString = options.authSource
? '?authSource=' + options.authSource
: '';
server = new mongo.ReplSet(servers);
} else {
server = new mongo.Server(options.host, options.port, options.options);
connectionUrl = 'mongodb://' + authString + memberString + '/' + options.dbName + optionsString;
}
this.db = new mongo.Db(options.dbName, server, { safe: true });
this.db.on('close', function() {
self.emit('disconnect');
self.stopHeartbeat();
});
var client = new mongo.MongoClient();
this.db.open(function (err, client) {
client.connect(connectionUrl, options.options, function(err, db) {
if (err) {
if (callback) callback(err);
} else {
self.db = db;
self.db.on('close', function() {
self.emit('disconnect');
self.stopHeartbeat();
});
var finish = function (err) {
self.client = client;
self.isConnected = true;

@@ -88,10 +94,3 @@ if (!err) {

if (options.authSource && options.username) {
// Authenticate with authSource
client.authenticate(options.username, options.password, {authSource: options.authSource}, finish);
} else if (options.username) {
client.authenticate(options.username, options.password, finish);
} else {
finish();
}
finish();
}

@@ -98,0 +97,0 @@ });

{
"author": "adrai",
"name": "viewmodel",
"version": "1.5.14",
"version": "1.5.15",
"private": false,

@@ -6,0 +6,0 @@ "main": "index.js",

@@ -40,2 +40,3 @@ # Introduction

// password: 'secret' // optional
// url: 'mongodb://user:pass@host:port/db?opts // optional
},

@@ -42,0 +43,0 @@ function(err, repository) {

@@ -0,1 +1,4 @@

## [v1.5.15](https://github.com/adrai/node-viewmodel/compare/v1.5.14...v1.5.15)
- Support mongo connection string
## [v1.5.14](https://github.com/adrai/node-viewmodel/compare/v1.5.13...v1.5.14)

@@ -2,0 +5,0 @@ - inmemory: now correctly instantiates with collectionName [#46](https://github.com/adrai/node-viewmodel/pull/46) thanks to [hilkeheremans](https://github.com/hilkeheremans)

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc