@xuda.io/xuda-dbs-plugin-xuda 1.0.146 → 1.0.147

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/package.json +1 -1
  2. package/studio.mjs +22 -17
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@xuda.io/xuda-dbs-plugin-xuda",
3
- "version": "1.0.146",
3
+ "version": "1.0.147",
4
4
  "description": "Xuda Database Socket for Xuda's proprietary structure powered by CouchDB",
5
5
  "scripts": {
6
6
  "pub": "npm version patch --force && npm publish --access public"
package/studio.mjs CHANGED
@@ -731,24 +731,29 @@ const query_db = async function (e, db, table_obj) {
731
731
  const doc = await db.find(opt);
732
732
  var mango_index_obj;
733
733
  if (doc?.warning?.includes("No matching index found")) {
734
- const index_name = `index_${e.table_id}_${new Date()
735
- .valueOf()
736
- .toString()}`;
737
- var index = [];
734
+ try {
735
+ const index_name = `index_${e.table_id}_${new Date()
736
+ .valueOf()
737
+ .toString()}`;
738
+ var index = [];
738
739
 
739
- for (const [key, val] of Object.entries(opt.selector)) {
740
- index.push(key);
740
+ for (const [key, val] of Object.entries(opt.selector)) {
741
+ index.push(key);
742
+ }
743
+ mango_index_obj = {
744
+ index: {
745
+ fields: index,
746
+ },
747
+ name: index_name,
748
+ ddoc: `mango_index_table_${e.table_id}`,
749
+ };
750
+ db.createIndex(mango_index_obj).then((result) => {
751
+ console.log(result);
752
+ });
753
+ throw new Error("creating index in progress");
754
+ } catch (err) {
755
+ return { code: -1, data: err.message };
741
756
  }
742
- mango_index_obj = {
743
- index: {
744
- fields: index,
745
- },
746
- name: index_name,
747
- ddoc: `mango_index_table_${e.table_id}`,
748
- };
749
- db.createIndex(mango_index_obj).then((result) => {
750
- console.log(result);
751
- });
752
757
  }
753
758
  return await done(doc);
754
759
  } catch (err) {
@@ -790,7 +795,7 @@ const query_db = async function (e, db, table_obj) {
790
795
  // };
791
796
  // await monitor_indexing();
792
797
  // throw new Error({ code: -88, data: "creating index" });
793
- throw new Error("creating index on progress");
798
+ throw new Error("creating index in progress");
794
799
  // const doc = await db.find(opt);
795
800
  // return await done(doc);
796
801
  } catch (err) {