beanbagdb 0.5.75 → 0.5.76

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "beanbagdb",
3
- "version": "0.5.75",
3
+ "version": "0.5.76",
4
4
  "description": "A JS library to introduce a schema layer to a No-SQL local database",
5
5
  "main": "src/index.js",
6
6
  "module": "src/index.js",
package/src/index.js CHANGED
@@ -268,21 +268,19 @@ export class BeanBagDB {
268
268
 
269
269
  let app_doc = { ... app_data.meta, version: latest_version}
270
270
  try {
271
- await this.save_setting_doc(app_data.meta.name, {
272
- value: app_doc,
273
- });
274
- } catch (error) {
275
- console.log(error)
276
- console.log("error in storing/updating beanbagdb_version")
277
- }
278
-
279
- try {
271
+ // modify the app setting doc
272
+ await this.modify_setting(app_data.meta.name,{value: app_doc,},"update")
273
+
274
+ // add a new log
280
275
  let new_log_doc = this._get_blank_doc("system_log")
281
276
  new_log_doc.data = {text,data:{steps},time:this.util_get_now_unix_timestamp(),app:app_data.meta.name}
282
277
  await this.db_api.insert(new_log_doc);
283
278
  console.log("init logged")
279
+
284
280
  } catch (error) {
285
281
  console.log(error)
282
+ console.log("error in storing/updating beanbagdb_version")
283
+ throw error
286
284
  }
287
285
  return app_doc
288
286
  }
@@ -547,9 +545,9 @@ export class BeanBagDB {
547
545
  // doc already exists,
548
546
  let doc = { ...doc_search.docs[0] };
549
547
  if (Array.isArray(value)) {
550
- doc.data.value = update_mode === "append" ? [...value, new_data] : new_data; // "update" mode replaces the value
548
+ doc.data.value = update_mode === "append" ? [...doc.data.value, value] : value; // "update" mode replaces the value
551
549
  } else {
552
- doc.data.value = update_mode === "append" ? { ...value, ...new_data } : new_data; // "update" mode replaces the value
550
+ doc.data.value = update_mode === "append" ? { ...doc.data.value, ...value } : value; // "update" mode replaces the value
553
551
  }
554
552
  // finally update it
555
553
  doc["meta"]["updated_on"] = this.util_get_now_unix_timestamp();
@@ -559,9 +557,11 @@ export class BeanBagDB {
559
557
 
560
558
  } else {
561
559
  // doc does not exists, generate a new one
562
- let new_doc = {value, name};
563
- let d = await this.create("system_setting",new_doc)
564
- return d;
560
+ let new_log_doc = this._get_blank_doc("system_setting")
561
+ new_log_doc.data = {value, name}
562
+ await this.db_api.insert(new_log_doc);
563
+
564
+
565
565
  }
566
566
  }
567
567
 
@@ -709,7 +709,7 @@ export class BeanBagDB {
709
709
  * @param {object} node2
710
710
  * @param {string} edge_name
711
711
  * @param {*} edge_label
712
- * @returns
712
+ * @returns {Object}
713
713
  */
714
714
  async create_edge(node1,node2,edge_name,edge_label=""){
715
715
  this._check_ready_to_use();
@@ -8,7 +8,7 @@ export const default_app = {
8
8
  name: "schema",
9
9
  description:"Meta-schema or the schema for defining other schemas",
10
10
  system_generated:true,
11
- version:0.80,
11
+ version:0.85,
12
12
  schema: {
13
13
  type: "object",
14
14
  additionalProperties: false,
@@ -98,7 +98,7 @@ export const default_app = {
98
98
  required :["primary_keys","non_editable_fields","encrypted_fields"]
99
99
  },
100
100
  },
101
- required: ["name","version","description","schema", "settings"],
101
+ required: ["name","description","schema", "settings"],
102
102
  },
103
103
  settings: {
104
104
  primary_keys: ["name"],