@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/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@budibase/server",
|
|
3
3
|
"email": "hi@budibase.com",
|
|
4
|
-
"version": "2.6.19-alpha.
|
|
4
|
+
"version": "2.6.19-alpha.12",
|
|
5
5
|
"description": "Budibase Web Server",
|
|
6
6
|
"main": "src/index.ts",
|
|
7
7
|
"repository": {
|
|
@@ -45,12 +45,12 @@
|
|
|
45
45
|
"license": "GPL-3.0",
|
|
46
46
|
"dependencies": {
|
|
47
47
|
"@apidevtools/swagger-parser": "10.0.3",
|
|
48
|
-
"@budibase/backend-core": "2.6.19-alpha.
|
|
49
|
-
"@budibase/client": "2.6.19-alpha.
|
|
50
|
-
"@budibase/pro": "2.6.19-alpha.
|
|
51
|
-
"@budibase/shared-core": "2.6.19-alpha.
|
|
52
|
-
"@budibase/string-templates": "2.6.19-alpha.
|
|
53
|
-
"@budibase/types": "2.6.19-alpha.
|
|
48
|
+
"@budibase/backend-core": "2.6.19-alpha.12",
|
|
49
|
+
"@budibase/client": "2.6.19-alpha.12",
|
|
50
|
+
"@budibase/pro": "2.6.19-alpha.12",
|
|
51
|
+
"@budibase/shared-core": "2.6.19-alpha.12",
|
|
52
|
+
"@budibase/string-templates": "2.6.19-alpha.12",
|
|
53
|
+
"@budibase/types": "2.6.19-alpha.12",
|
|
54
54
|
"@bull-board/api": "3.7.0",
|
|
55
55
|
"@bull-board/koa": "3.9.4",
|
|
56
56
|
"@elastic/elasticsearch": "7.10.0",
|
|
@@ -193,5 +193,5 @@
|
|
|
193
193
|
}
|
|
194
194
|
}
|
|
195
195
|
},
|
|
196
|
-
"gitHead": "
|
|
196
|
+
"gitHead": "29935057b058f97e80a208b0cfdcf65b0ce150c2"
|
|
197
197
|
}
|
|
@@ -415,7 +415,7 @@ export async function exportRows(ctx: UserCtx) {
|
|
|
415
415
|
|
|
416
416
|
result = await outputProcessing(table, response)
|
|
417
417
|
} else if (query) {
|
|
418
|
-
let searchResponse = await
|
|
418
|
+
let searchResponse = await search(ctx)
|
|
419
419
|
result = searchResponse.rows
|
|
420
420
|
}
|
|
421
421
|
|
|
@@ -186,11 +186,7 @@ export async function destroy(ctx: any) {
|
|
|
186
186
|
export async function bulkImport(ctx: any) {
|
|
187
187
|
const db = context.getAppDB()
|
|
188
188
|
const table = await sdk.tables.getTable(ctx.params.tableId)
|
|
189
|
-
const { rows } = ctx.request.body
|
|
190
|
-
await handleDataImport(ctx.user, table, rows)
|
|
191
|
-
|
|
192
|
-
// Ensure auto id and other table updates are persisted
|
|
193
|
-
await db.put(table)
|
|
194
|
-
|
|
189
|
+
const { rows, identifierFields } = ctx.request.body
|
|
190
|
+
await handleDataImport(ctx.user, table, rows, identifierFields)
|
|
195
191
|
return table
|
|
196
192
|
}
|
|
@@ -149,7 +149,12 @@ export function importToRows(
|
|
|
149
149
|
return finalData
|
|
150
150
|
}
|
|
151
151
|
|
|
152
|
-
export async function handleDataImport(
|
|
152
|
+
export async function handleDataImport(
|
|
153
|
+
user: any,
|
|
154
|
+
table: any,
|
|
155
|
+
rows: any,
|
|
156
|
+
identifierFields: Array<string> = []
|
|
157
|
+
) {
|
|
153
158
|
const schema: unknown = table.schema
|
|
154
159
|
|
|
155
160
|
if (!rows || !isRows(rows) || !isSchema(schema)) {
|
|
@@ -161,6 +166,32 @@ export async function handleDataImport(user: any, table: any, rows: any) {
|
|
|
161
166
|
|
|
162
167
|
let finalData: any = importToRows(data, table, user)
|
|
163
168
|
|
|
169
|
+
//Set IDs of finalData to match existing row if an update is expected
|
|
170
|
+
if (identifierFields.length > 0) {
|
|
171
|
+
const allDocs = await db.allDocs(
|
|
172
|
+
getRowParams(table._id, null, {
|
|
173
|
+
include_docs: true,
|
|
174
|
+
})
|
|
175
|
+
)
|
|
176
|
+
allDocs.rows
|
|
177
|
+
.map(existingRow => existingRow.doc)
|
|
178
|
+
.forEach((doc: any) => {
|
|
179
|
+
finalData.forEach((finalItem: any) => {
|
|
180
|
+
let match = true
|
|
181
|
+
for (const field of identifierFields) {
|
|
182
|
+
if (finalItem[field] !== doc[field]) {
|
|
183
|
+
match = false
|
|
184
|
+
break
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
if (match) {
|
|
188
|
+
finalItem._id = doc._id
|
|
189
|
+
finalItem._rev = doc._rev
|
|
190
|
+
}
|
|
191
|
+
})
|
|
192
|
+
})
|
|
193
|
+
}
|
|
194
|
+
|
|
164
195
|
await quotas.addRows(finalData.length, () => db.bulkDocs(finalData), {
|
|
165
196
|
tableId: table._id,
|
|
166
197
|
})
|