@xuda.io/xuda-dbs-plugin-xuda 1.0.72 → 1.0.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.
Files changed (2) hide show
  1. package/package.json +1 -1
  2. package/server.js +7 -14
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@xuda.io/xuda-dbs-plugin-xuda",
3
- "version": "1.0.72",
3
+ "version": "1.0.76",
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/server.js CHANGED
@@ -1000,7 +1000,7 @@ exports.create = async (params, setup_doc, resolve, reject) => {
1000
1000
  doc.udfIndex = index_ret.data;
1001
1001
  const ret = await check_unique(e, doc, table_obj, db, app_id_reference);
1002
1002
  if (ret.code < 0) {
1003
- return ret;
1003
+ return reject(ret.data);
1004
1004
  }
1005
1005
  try {
1006
1006
  const body = await db.insert(doc);
@@ -1009,20 +1009,10 @@ exports.create = async (params, setup_doc, resolve, reject) => {
1009
1009
  return reject(error);
1010
1010
  }
1011
1011
  };
1012
- var ret;
1013
1012
  if (Array.isArray(e.table_data)) {
1014
- ret = await batch();
1015
- if (ret.code < 0) {
1016
- return reject(ret.data);
1017
- }
1018
- return resolve(ret.data);
1013
+ return await batch();
1019
1014
  }
1020
-
1021
- ret = await single();
1022
- if (ret.code < 0) {
1023
- return reject(ret.data);
1024
- }
1025
- resolve(ret.data);
1015
+ return await single();
1026
1016
  };
1027
1017
  exports.read = async (params, setup_doc, resolve, reject) => {
1028
1018
  const e = params.e;
@@ -1726,8 +1716,11 @@ exports.update = async (params, setup_doc, resolve, reject) => {
1726
1716
  const app_id_reference = params.app_id_reference;
1727
1717
  const table_obj = params.table_obj;
1728
1718
  try {
1719
+ if (e.row_id === "newRecord") {
1720
+ return this.create(params, setup_doc, resolve, reject);
1721
+ }
1729
1722
  var doc = await db.get(e.row_id, {});
1730
- let data = doc.udfData.data;
1723
+ // let data = doc.udfData.data;
1731
1724
  var error = undefined;
1732
1725
  if (!e.field_id && !e.data) {
1733
1726
  error = "Invalid field_id or data object to save";