@cocreate/mongodb 1.10.4 → 1.10.6

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,17 @@
1
+ ## [1.10.6](https://github.com/CoCreate-app/CoCreate-mongodb/compare/v1.10.5...v1.10.6) (2023-10-25)
2
+
3
+
4
+ ### Bug Fixes
5
+
6
+ * ensure a single connection is created ([f3856af](https://github.com/CoCreate-app/CoCreate-mongodb/commit/f3856afb83b59c314f73c11654f8aceaf4891bc7))
7
+
8
+ ## [1.10.5](https://github.com/CoCreate-app/CoCreate-mongodb/compare/v1.10.4...v1.10.5) (2023-10-25)
9
+
10
+
11
+ ### Bug Fixes
12
+
13
+ * delete mongoClient if an error occures ([b1942c7](https://github.com/CoCreate-app/CoCreate-mongodb/commit/b1942c7a6932c4552c14af11462f67debce9fc9c))
14
+
1
15
  ## [1.10.4](https://github.com/CoCreate-app/CoCreate-mongodb/compare/v1.10.3...v1.10.4) (2023-10-25)
2
16
 
3
17
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cocreate/mongodb",
3
- "version": "1.10.4",
3
+ "version": "1.10.6",
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
@@ -6,7 +6,7 @@ const clients = new Map()
6
6
  async function dbClient(data) {
7
7
  if (data.storageUrl) {
8
8
  let client = clients.get(data.storageUrl)
9
- if (!client) {
9
+ if (!client && !clients.has(data.storageUrl)) {
10
10
  try {
11
11
  clients.set(data.storageUrl, client)
12
12
  client = await MongoClient.connect(data.storageUrl, { useNewUrlParser: true, useUnifiedTopology: true });
@@ -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 || 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 || 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 || client.status === false)
247
247
  return data
248
248
 
249
249
  let dataTransferedIn = 0