corebasic 1.0.148 → 1.0.150

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.
Files changed (2) hide show
  1. package/libs/dip.js +15 -3
  2. package/package.json +1 -1
package/libs/dip.js CHANGED
@@ -56,15 +56,27 @@ export const IdempotentDip = () => {
56
56
 
57
57
 
58
58
  export const idip = async (message, callback, cleanup) => {
59
+ if (!callback)
60
+ throw {message: "Dip.idip() callback argument undefined"}
61
+ if (!cleanup)
62
+ throw {message: "Dip.idip() cleanup argument undefined"}
63
+ async function doCleanup(IDip) {
64
+ if (typeof cleanup === 'object') {
65
+ for (let collection in cleanup)
66
+ await IDip.cleanup(collection, { _id: {$in: cleanup[collection]} })
67
+ } else
68
+ await cleanup(IDip)
69
+ }
70
+
59
71
  let IDip = await IdempotentDip().new(message.meta, message.txn)
60
72
  if (!IDip) {
61
- IDip = IdempotentDip().new(message.meta, message.txn, {blank: true})
62
- await cleanup(IDip)
73
+ IDip = await IdempotentDip().new(message.meta, message.txn, {blank: true})
74
+ await doCleanup(IDip)
63
75
  return
64
76
  }
65
77
  await callback(IDip)
66
78
  await IDip.finish()
67
- await cleanup(IDip)
79
+ await doCleanup(IDip)
68
80
  }
69
81
 
70
82
 
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "corebasic",
3
3
  "type": "module",
4
- "version": "1.0.148",
4
+ "version": "1.0.150",
5
5
  "description": "",
6
6
  "main": "index.js",
7
7
  "scripts": {