corebasic 1.0.184 → 1.0.186

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/elabase.js +11 -2
  2. package/package.json +1 -1
package/libs/elabase.js CHANGED
@@ -125,13 +125,22 @@ export function batchAbort(batch) { // Mandatory to prevent meory leak due to d
125
125
  }
126
126
 
127
127
  export const batch = async (callback) => { // Convenience function with auto lifecyle management and auto submit when callback returns. abort is called appropriately.
128
- const batch = Dip.batchBegin()
128
+ /**
129
+ * Usage:
130
+ * const result = await Dip.batch(async batch => {
131
+ * for (let i = 0; i < 45000; i++)
132
+ * Dip.insert({...meta, batch}, collection, {_id: i})
133
+ * })
134
+ *
135
+ * Note: Nested batch is supported as they are just independant batches.
136
+ */
137
+ const batch = batchBegin()
129
138
 
130
139
  try {
131
140
  await callback(batch)
132
141
  return await batchSubmit(batch)
133
142
  } catch (err) {
134
- Dip.batchAbort(batch)
143
+ batchAbort(batch)
135
144
  throw err
136
145
  }
137
146
  }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "corebasic",
3
3
  "type": "module",
4
- "version": "1.0.184",
4
+ "version": "1.0.186",
5
5
  "description": "",
6
6
  "main": "index.js",
7
7
  "scripts": {