@xuda.io/xuda-dbs-plugin-xuda 1.0.12 → 1.0.14
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/index.mjs +22 -17
- package/package.json +1 -1
package/index.mjs
CHANGED
@@ -68,7 +68,9 @@ const check_unique = async function (docP, table_obj) {
|
|
68
68
|
keyValue.join(",") +
|
69
69
|
"]]";
|
70
70
|
try {
|
71
|
-
const json = await _this.runtime_xuda_driver("runtime_get_index", e);
|
71
|
+
// const json = await _this.runtime_xuda_driver("runtime_get_index", e);
|
72
|
+
e.view = "db_index";
|
73
|
+
const json = await _this.Read(_, e, db, app_id_reference, table_obj);
|
72
74
|
|
73
75
|
// var data;
|
74
76
|
|
@@ -154,7 +156,7 @@ const get_index_json = async function (docInP, table_obj) {
|
|
154
156
|
}
|
155
157
|
};
|
156
158
|
|
157
|
-
export const Create = async (_, e, db, table_obj) => {
|
159
|
+
export const Create = async (_, e, db, app_id_reference, table_obj) => {
|
158
160
|
const batch = async function () {
|
159
161
|
var docs = [];
|
160
162
|
try {
|
@@ -229,7 +231,7 @@ export const Create = async (_, e, db, table_obj) => {
|
|
229
231
|
}
|
230
232
|
return await single();
|
231
233
|
};
|
232
|
-
export const Read = async (_, e, db, table_obj) => {
|
234
|
+
export const Read = async (_, e, db, app_id_reference, table_obj) => {
|
233
235
|
var key;
|
234
236
|
|
235
237
|
const runtime_get_mango_data = async function () {
|
@@ -509,11 +511,13 @@ export const Read = async (_, e, db, table_obj) => {
|
|
509
511
|
|
510
512
|
if (e.sort_fields && JSON.parse(e.sort_fields).length) {
|
511
513
|
opt.sort = JSON.parse(e.sort_fields);
|
512
|
-
|
513
|
-
|
514
|
-
|
515
|
-
[
|
516
|
-
|
514
|
+
if (opt.sort) {
|
515
|
+
for await (const [key, val] of Object.entries(opt.sort)) {
|
516
|
+
var field_name = val.colId;
|
517
|
+
opt.sort[key] = {
|
518
|
+
["udfData.data." + field_name]: val.sort,
|
519
|
+
};
|
520
|
+
}
|
517
521
|
}
|
518
522
|
}
|
519
523
|
|
@@ -721,11 +725,12 @@ export const Read = async (_, e, db, table_obj) => {
|
|
721
725
|
}
|
722
726
|
if (!e.sort_fields || !JSON.parse(e.sort_fields).length) {
|
723
727
|
// added 2021 09 10
|
724
|
-
|
725
|
-
|
726
|
-
|
727
|
-
|
728
|
-
|
728
|
+
if (opt.sort) {
|
729
|
+
for await (const [key, val] of Object.entries(opt.sort)) {
|
730
|
+
opt.sort[key] = {
|
731
|
+
["udfData.data." + val]: e.sortOrder === "des" ? "desc" : "asc",
|
732
|
+
};
|
733
|
+
}
|
729
734
|
}
|
730
735
|
}
|
731
736
|
|
@@ -762,7 +767,7 @@ export const Read = async (_, e, db, table_obj) => {
|
|
762
767
|
|
763
768
|
// xuda
|
764
769
|
var cache_string = JSON.stringify(opt);
|
765
|
-
|
770
|
+
|
766
771
|
if (
|
767
772
|
// __.CACHE_QUERY_REQ[app_id_reference] &&
|
768
773
|
// __.CACHE_QUERY_REQ[app_id_reference][e.table_id] &&
|
@@ -925,7 +930,7 @@ export const Read = async (_, e, db, table_obj) => {
|
|
925
930
|
}
|
926
931
|
return await runtime_get_mango_data();
|
927
932
|
};
|
928
|
-
export const Update = async (_, e, db, table_obj) => {
|
933
|
+
export const Update = async (_, e, db, app_id_reference, table_obj) => {
|
929
934
|
try {
|
930
935
|
const doc = await db.get(e.row_id, {});
|
931
936
|
let data = doc.udfData.data;
|
@@ -976,7 +981,7 @@ export const Update = async (_, e, db, table_obj) => {
|
|
976
981
|
return { code: -550, data: error };
|
977
982
|
}
|
978
983
|
};
|
979
|
-
export const Delete = async (_, e, db, table_obj) => {
|
984
|
+
export const Delete = async (_, e, db, app_id_reference, table_obj) => {
|
980
985
|
const data = await db.fetch({ keys: e.ids });
|
981
986
|
for await (var val of data.rows) {
|
982
987
|
var doc = val.doc;
|
@@ -1003,7 +1008,7 @@ export const Delete = async (_, e, db, table_obj) => {
|
|
1003
1008
|
}
|
1004
1009
|
};
|
1005
1010
|
|
1006
|
-
export const Restore = async (_, e, db, table_obj) => {
|
1011
|
+
export const Restore = async (_, e, db, app_id_reference, table_obj) => {
|
1007
1012
|
var docs_to_restore = [];
|
1008
1013
|
const data = await db.fetch({ keys: e.ids });
|
1009
1014
|
|
package/package.json
CHANGED