@cocreate/mongodb 1.10.4 → 1.10.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,3 +1,10 @@
1
+ ## [1.10.5](https://github.com/CoCreate-app/CoCreate-mongodb/compare/v1.10.4...v1.10.5) (2023-10-25)
2
+
3
+
4
+ ### Bug Fixes
5
+
6
+ * delete mongoClient if an error occures ([b1942c7](https://github.com/CoCreate-app/CoCreate-mongodb/commit/b1942c7a6932c4552c14af11462f67debce9fc9c))
7
+
1
8
  ## [1.10.4](https://github.com/CoCreate-app/CoCreate-mongodb/compare/v1.10.3...v1.10.4) (2023-10-25)
2
9
 
3
10
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cocreate/mongodb",
3
- "version": "1.10.4",
3
+ "version": "1.10.5",
4
4
  "description": "A simple mongodb component in vanilla javascript. Easily configured using HTML5 data-attributes and/or JavaScript API.",
5
5
  "keywords": [
6
6
  "mongodb",
package/src/index.js CHANGED
@@ -10,8 +10,8 @@ async function dbClient(data) {
10
10
  try {
11
11
  clients.set(data.storageUrl, client)
12
12
  client = await MongoClient.connect(data.storageUrl, { useNewUrlParser: true, useUnifiedTopology: true });
13
- clients.set(data.storageUrl, client)
14
13
  } catch (error) {
14
+ clients.delete(data.storageUrl)
15
15
  console.error(`${data.organization_id}: storageName ${data.storageName} failed to connect to mongodb`)
16
16
  errorHandler(data, error)
17
17
  return { status: false }
@@ -43,7 +43,7 @@ function database(action, data) {
43
43
 
44
44
  try {
45
45
  const client = await dbClient(data)
46
- if (!client.status)
46
+ if (client.status === false)
47
47
  return data
48
48
  if (action == 'readDatabase') {
49
49
  const db = client.db().admin();
@@ -97,7 +97,7 @@ function array(action, data) {
97
97
 
98
98
  try {
99
99
  const client = await dbClient(data)
100
- if (!client.status)
100
+ if (client.status === false)
101
101
  return data
102
102
 
103
103
  if (data.request)
@@ -243,7 +243,7 @@ function object(action, data) {
243
243
  return new Promise(async (resolve, reject) => {
244
244
  try {
245
245
  const client = await dbClient(data)
246
- if (!client.status)
246
+ if (client.status === false)
247
247
  return data
248
248
 
249
249
  let dataTransferedIn = 0