corebasic 1.0.185 → 1.0.187

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/libs/dip.js CHANGED
@@ -12,6 +12,7 @@ export const batchBegin = Elabase.batchBegin
12
12
  export const batchAbort = Elabase.batchAbort
13
13
  export const batchSubmit = Elabase.batchSubmit
14
14
  export const batch = Elabase.batch
15
+ export const global = Elabase.global
15
16
 
16
17
  export const shard_stats = Elabase.shard_stats
17
18
  export let config = Elabase.config
package/libs/elabase.js CHANGED
@@ -54,6 +54,15 @@ export function start(dbName) {
54
54
  }
55
55
  }
56
56
 
57
+ export const global = args => {
58
+ let obj = { ...args, company: "GLOBAL", outlet: "GLOBAL" }
59
+ return {
60
+ ...obj,
61
+ setOutlet: outlet => {return {...obj, outlet}},
62
+ setCompany: company => {return {...obj, company}},
63
+ }
64
+ }
65
+
57
66
  function validate_collection(collection, fn_name) {
58
67
  if ((typeof collection === 'string' && collection.trim() === "") || (typeof collection !== 'string' && !Array.isArray(collection)) || (Array.isArray(collection) && (!collection.length || collection.some(item => typeof item !== "string" || item.trim() === "")))) {
59
68
  throw {message: `Error: Invalid collection ${fn_name}`}
@@ -125,6 +134,15 @@ export function batchAbort(batch) { // Mandatory to prevent meory leak due to d
125
134
  }
126
135
 
127
136
  export const batch = async (callback) => { // Convenience function with auto lifecyle management and auto submit when callback returns. abort is called appropriately.
137
+ /**
138
+ * Usage:
139
+ * const result = await Dip.batch(async batch => {
140
+ * for (let i = 0; i < 45000; i++)
141
+ * Dip.insert({...meta, batch}, collection, {_id: i})
142
+ * })
143
+ *
144
+ * Note: Nested batch is supported as they are just independant batches.
145
+ */
128
146
  const batch = batchBegin()
129
147
 
130
148
  try {
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "corebasic",
3
3
  "type": "module",
4
- "version": "1.0.185",
4
+ "version": "1.0.187",
5
5
  "description": "",
6
6
  "main": "index.js",
7
7
  "scripts": {