@xuda.io/xuda-dbs-plugin-xuda 1.0.112 → 1.0.114

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 +21 -14
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@xuda.io/xuda-dbs-plugin-xuda",
3
- "version": "1.0.112",
3
+ "version": "1.0.114",
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
@@ -51,6 +51,7 @@ const check_unique = async function (e, docP, table_obj, db) {
51
51
  valSegment
52
52
  ).props.fieldType;
53
53
  let _val = await get_cast_val(
54
+ e,
54
55
  "check_unique",
55
56
  valSegment,
56
57
  _fieldType,
@@ -132,6 +133,7 @@ const get_index_json = async function (docInP, table_obj) {
132
133
  }
133
134
 
134
135
  let _val = await get_cast_val(
136
+ e,
135
137
  "get_index_json",
136
138
  field_obj.id,
137
139
  field_obj.props.fieldType,
@@ -168,19 +170,20 @@ const find_item_by_key = function (arr, key, val) {
168
170
  });
169
171
  };
170
172
 
171
- const get_cast_val = async function (source, attributeP, typeP, valP) {
172
- return xu_cast(
173
- typeP,
174
- valP,
175
- function (res) {
176
- var msg = `error converting ${attributeP} from ${valP} to ${typeP}`;
177
- console.error(source, msg);
178
- },
179
- function (res) {
180
- var msg = `type mismatch auto conversion made to ${attributeP} from value ${valP} to ${typeP}`;
181
- console.warn(source, msg);
182
- }
183
- );
173
+ const get_cast_val = async function (e, source, attributeP, typeP, valP) {
174
+ const success = function (res) {
175
+ var msg = `error converting ${attributeP} from ${valP} to ${typeP}`;
176
+ console.error(source, msg);
177
+ };
178
+ const fail = function (res) {
179
+ var msg = `type mismatch auto conversion made to ${attributeP} from value ${valP} to ${typeP}`;
180
+ console.warn(source, msg);
181
+ };
182
+
183
+ if (e.xu_cast) {
184
+ return e.xu_cast(typeP, valP, success, fail);
185
+ }
186
+ return xu_cast(typeP, valP, success, fail);
184
187
  };
185
188
 
186
189
  const get_opt = function (e, table_obj) {
@@ -1100,7 +1103,7 @@ const query_db = async function (e, db, table_obj) {
1100
1103
 
1101
1104
  var view_opt = undefined;
1102
1105
  if (key) {
1103
- opt = {
1106
+ view_opt = {
1104
1107
  key: key,
1105
1108
  include_docs: !e.ids && view !== "db_index_reduce",
1106
1109
  limit: limit,
@@ -1154,6 +1157,7 @@ const query_db = async function (e, db, table_obj) {
1154
1157
  );
1155
1158
 
1156
1159
  let field_value = await get_cast_val(
1160
+ e,
1157
1161
  "dbs_update",
1158
1162
  e.field_id,
1159
1163
  _tableFieldsObj.props.fieldType,
@@ -1256,6 +1260,7 @@ export const create = async (params, resolve, reject) => {
1256
1260
  var doc = {};
1257
1261
  for await (const val of table_obj.tableFields) {
1258
1262
  doc[val.data.field_id] = await get_cast_val(
1263
+ e,
1259
1264
  "dbs_create",
1260
1265
  val.data.field_id,
1261
1266
  val.props.fieldType,
@@ -1381,6 +1386,7 @@ export const update = async (params, resolve, reject) => {
1381
1386
  }
1382
1387
 
1383
1388
  doc.udfData.data[e.field_id] = await get_cast_val(
1389
+ e,
1384
1390
  "dbs_update",
1385
1391
  e.field_id,
1386
1392
  _tableFieldsObj.props.fieldType,
@@ -1403,6 +1409,7 @@ export const update = async (params, resolve, reject) => {
1403
1409
  }
1404
1410
 
1405
1411
  doc.udfData.data[key] = await get_cast_val(
1412
+ e,
1406
1413
  "dbs_update",
1407
1414
  key,
1408
1415
  _tableFieldsObj.props.fieldType,