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

@examgoal/mongodb

Package Overview
Dependencies
Maintainers
1
Versions
14
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@examgoal/mongodb - npm Package Compare versions

Comparing version 1.1.0 to 1.2.0

2

dist/index.d.ts

@@ -7,5 +7,7 @@ import { Db, MongoClient } from 'mongodb';

private isConnected;
private connectPromise;
constructor(config: ConfigOptions);
private resetClient;
getDb(name?: string): Promise<Db>;
close(force?: boolean): Promise<void>;
get client(): MongoClient;

@@ -12,0 +14,0 @@ get name(): string;

19

dist/index.js

@@ -7,2 +7,3 @@ "use strict";

this.isConnected = false;
this.connectPromise = null;
this.configuration = config;

@@ -13,12 +14,12 @@ this.mongoClient = new mongodb_1.MongoClient(config.uri, config.mongodbOptions || {});

resetClient() {
this.mongoClient.removeListener("serverClosed", this.resetClient);
if (this.mongoClient) {
this.mongoClient.removeAllListeners("serverClosed");
}
this.mongoClient = new mongodb_1.MongoClient(this.configuration.uri, this.configuration.mongodbOptions || {});
this.mongoClient.on("serverClosed", this.resetClient);
this.isConnected = false;
this.connectPromise = null;
}
getDb(name) {
return new Promise((resolve, reject) => {
if (this.isConnected) {
return resolve(this.mongoClient.db(name || this.configuration.db));
}
this.connectPromise = this.connectPromise || new Promise((resolve, reject) => {
this.mongoClient.connect()

@@ -35,5 +36,13 @@ .then(res => {

reject(err);
setImmediate(() => {
this.connectPromise = null;
});
});
});
return this.connectPromise;
}
async close(force) {
this.isConnected = false;
await this.mongoClient.close(force);
}
get client() {

@@ -40,0 +49,0 @@ return this.mongoClient;

{
"name": "@examgoal/mongodb",
"version": "1.1.0",
"version": "1.2.0",
"description": "MongoDB Session Management Helper for ExpressJS or any Node JS Projects",

@@ -5,0 +5,0 @@ "main": "./dist/index.js",

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