@cocreate/mongodb 1.18.7 → 1.19.0

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.19.0](https://github.com/CoCreate-app/CoCreate-mongodb/compare/v1.18.7...v1.19.0) (2024-11-02)
2
+
3
+
4
+ ### Features
5
+
6
+ * allowDiskUse, set $storage, $database, $array if not included ([39a71d9](https://github.com/CoCreate-app/CoCreate-mongodb/commit/39a71d9c29b6432dae1951fcad1ce88e3fbe817e))
7
+
1
8
  ## [1.18.7](https://github.com/CoCreate-app/CoCreate-mongodb/compare/v1.18.6...v1.18.7) (2024-07-05)
2
9
 
3
10
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cocreate/mongodb",
3
- "version": "1.18.7",
3
+ "version": "1.19.0",
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
@@ -302,9 +302,12 @@ function object(method, data) {
302
302
  if (!Array.isArray($array))
303
303
  $array = [data[type][i].$array]
304
304
 
305
- $storage.push(data.storageName)
306
- $database.push(database)
307
- $array.push(array)
305
+ if (!$storage.includes(data.storageName))
306
+ $storage.push(data.storageName)
307
+ if (!$database.includes(database))
308
+ $database.push(database)
309
+ if (!$array.includes(array))
310
+ $array.push(array)
308
311
 
309
312
  delete data[type][i].$storage
310
313
  delete data[type][i].$database
@@ -422,8 +425,12 @@ function object(method, data) {
422
425
 
423
426
  dataTransferedOut += getBytes({ query, projection, sort, index, limit })
424
427
 
425
- let document = ''
426
- const cursor = arrayObj.find(query, projection).sort(sort).skip(index).limit(limit);
428
+ let cursor, document = ''
429
+ if (Object.keys(sort).length > 0)
430
+ cursor = arrayObj.find(query, projection).sort(sort).skip(index).limit(limit).allowDiskUse(true);
431
+ else
432
+ cursor = arrayObj.find(query, projection).sort(sort).skip(index).limit(limit);
433
+
427
434
  if (!(await cursor.hasNext()) && method === 'update' && data.upsert)
428
435
  document = { _id: ObjectId(data[type][i]._id) }
429
436