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

informa-db.js

Package Overview
Dependencies
Maintainers
1
Versions
31
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

informa-db.js - npm Package Compare versions

Comparing version 1.0.5 to 1.0.6

.env

1

.eslintrc.js

@@ -20,4 +20,5 @@ module.exports = {

"no-param-reassign": "off",
"global-require": "off",
"no-underscore-dangle": "off",
},
};

21

index.js
const fs = require('fs');
let mongo;
let MongoClient;
let mongo;
try {
mongo = require('mongodb');
MongoClient = mongo.MongoClient;
} catch (err) {
mongo = null;
MongoClient = null;
}
class Db {

@@ -39,4 +46,5 @@ constructor(file, defaultStr, isMongo, db, collection) {

if (dis.isMongo) {
mongo = (await import('mongodb')).default;
MongoClient = mongo.MongoClient;
if (!mongo) {
throw new Error('Mongodb is not installed. Please install it.');
}
dis.client = await MongoClient.connect(file, {

@@ -78,6 +86,5 @@ useNewUrlParser: true,

process.on('exit', dis.client.close);
// dis.value = dis.genProxy(dis.readOnlyValue);
} else {
if (!fs.existsSync(file)) {
fs.writeFileSync(file, defaultStr ?? '{}', (err) => {
fs.writeFileSync(file, defaultStr || '{}', (err) => {
if (err) {

@@ -89,3 +96,2 @@ throw err;

dis.readOnlyValue = JSON.parse(fs.readFileSync(file, 'utf8'));
// dis.value = dis.genProxy(dis.readOnlyValue);
}

@@ -119,3 +125,2 @@ dis.saveOnChange = true;

).map((val) => { const v = val; delete v._id; return v; });
// this.value = this.genProxy(this.readOnlyValue);
return this.readOnlyValue;

@@ -163,3 +168,1 @@ }

module.exports = Db;
// Hey u still here?
//
{
"name": "informa-db.js",
"version": "1.0.5",
"version": "1.0.6",
"description": "DataBases made easier",

@@ -10,2 +10,4 @@ "main": "index.js",

"devDependencies": {
"mongodb": "^3.5.8",
"dotenv": "^8.2.0",
"eslint": "^6.8.0",

@@ -18,6 +20,3 @@ "eslint-config-airbnb": "^18.1.0",

"eslint-plugin-react-hooks": "^2.5.0"
},
"dependencies": {
"mongodb": "^3.5.8"
}
}

@@ -54,3 +54,3 @@ # Informa-Db.js

Collection name, defaulting to "db"
### Db function and properties
### Db class
#### Db.readOnlyValue<Any>

@@ -57,0 +57,0 @@ File/collection content

@@ -0,1 +1,2 @@

require('dotenv').config();
const Db = require('./index.js');

@@ -6,5 +7,5 @@

// const ee = test.value.length;
// test.value = [];
test.value[test.value.length] = { ee: 'eeeeee' };
test.value = [];
test.value.push({ ee: 'eeeeee' });
console.log(test.value);
})();
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