@budibase/server 2.6.19-alpha.10 → 2.6.19-alpha.12
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/builder/assets/{index.7b26bbdb.js → index.ccf74017.js} +242 -242
- package/builder/index.html +1 -1
- package/dist/automation.js +1 -1
- package/dist/automation.js.map +2 -2
- package/dist/index.js +26 -5
- package/dist/index.js.map +2 -2
- package/package.json +8 -8
- package/src/api/controllers/row/internal.ts +1 -1
- package/src/api/controllers/table/internal.ts +2 -6
- package/src/api/controllers/table/utils.ts +32 -1
package/dist/index.js
CHANGED
|
@@ -22642,7 +22642,7 @@ function importToRows(data, table2, user2 = null) {
|
|
|
22642
22642
|
}
|
|
22643
22643
|
return finalData;
|
|
22644
22644
|
}
|
|
22645
|
-
async function handleDataImport(user2, table2, rows2) {
|
|
22645
|
+
async function handleDataImport(user2, table2, rows2, identifierFields = []) {
|
|
22646
22646
|
const schema = table2.schema;
|
|
22647
22647
|
if (!rows2 || !isRows(rows2) || !isSchema(schema)) {
|
|
22648
22648
|
return table2;
|
|
@@ -22650,6 +22650,28 @@ async function handleDataImport(user2, table2, rows2) {
|
|
|
22650
22650
|
const db = context_exports.getAppDB();
|
|
22651
22651
|
const data = parse3(rows2, schema);
|
|
22652
22652
|
let finalData = importToRows(data, table2, user2);
|
|
22653
|
+
if (identifierFields.length > 0) {
|
|
22654
|
+
const allDocs = await db.allDocs(
|
|
22655
|
+
getRowParams2(table2._id, null, {
|
|
22656
|
+
include_docs: true
|
|
22657
|
+
})
|
|
22658
|
+
);
|
|
22659
|
+
allDocs.rows.map((existingRow) => existingRow.doc).forEach((doc) => {
|
|
22660
|
+
finalData.forEach((finalItem) => {
|
|
22661
|
+
let match = true;
|
|
22662
|
+
for (const field of identifierFields) {
|
|
22663
|
+
if (finalItem[field] !== doc[field]) {
|
|
22664
|
+
match = false;
|
|
22665
|
+
break;
|
|
22666
|
+
}
|
|
22667
|
+
}
|
|
22668
|
+
if (match) {
|
|
22669
|
+
finalItem._id = doc._id;
|
|
22670
|
+
finalItem._rev = doc._rev;
|
|
22671
|
+
}
|
|
22672
|
+
});
|
|
22673
|
+
});
|
|
22674
|
+
}
|
|
22653
22675
|
await quotas_exports4.addRows(finalData.length, () => db.bulkDocs(finalData), {
|
|
22654
22676
|
tableId: table2._id
|
|
22655
22677
|
});
|
|
@@ -32166,7 +32188,7 @@ async function exportRows(ctx) {
|
|
|
32166
32188
|
})).rows.map((row2) => row2.doc);
|
|
32167
32189
|
result = await outputProcessing(table2, response);
|
|
32168
32190
|
} else if (query3) {
|
|
32169
|
-
let searchResponse = await
|
|
32191
|
+
let searchResponse = await search3(ctx);
|
|
32170
32192
|
result = searchResponse.rows;
|
|
32171
32193
|
}
|
|
32172
32194
|
let rows2 = [];
|
|
@@ -34031,9 +34053,8 @@ async function destroy11(ctx) {
|
|
|
34031
34053
|
async function bulkImport(ctx) {
|
|
34032
34054
|
const db = context_exports.getAppDB();
|
|
34033
34055
|
const table2 = await sdk_default.tables.getTable(ctx.params.tableId);
|
|
34034
|
-
const { rows: rows2 } = ctx.request.body;
|
|
34035
|
-
await handleDataImport(ctx.user, table2, rows2);
|
|
34036
|
-
await db.put(table2);
|
|
34056
|
+
const { rows: rows2, identifierFields } = ctx.request.body;
|
|
34057
|
+
await handleDataImport(ctx.user, table2, rows2, identifierFields);
|
|
34037
34058
|
return table2;
|
|
34038
34059
|
}
|
|
34039
34060
|
var import_lodash11, import_fp7;
|