-
Notifications
You must be signed in to change notification settings - Fork 5.3k
/
Copy pathdelete-record.mjs
45 lines (42 loc) · 1.27 KB
/
delete-record.mjs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
import airtable from "../../airtable_oauth.app.mjs";
import common from "../common/common.mjs";
export default {
key: "airtable_oauth-delete-record",
name: "Delete Record",
description: "Delete a selected record from a table. [See the documentation](https://airtable.com/developers/web/api/delete-record)",
version: "0.0.11",
type: "action",
props: {
...common.props,
recordId: {
propDefinition: [
airtable,
"recordId",
({
baseId, tableId,
}) => ({
baseId: baseId.value,
tableId: tableId.value,
}),
],
},
},
async run({ $ }) {
const baseId = this.baseId?.value ?? this.baseId;
const tableId = this.tableId?.value ?? this.tableId;
const recordId = this.recordId?.value ?? this.recordId;
this.airtable.validateRecordID(recordId);
let response;
try {
response = await this.airtable.deleteRecord({
baseId,
tableId,
recordId,
});
} catch (err) {
this.airtable.throwFormattedError(err);
}
$.export("$summary", `Deleted record "${this.recordId?.label || recordId}" from ${this.baseId?.label || baseId}: [${this.tableId?.label || tableId}](https://airtable.com/${baseId}/${tableId})`);
return response;
},
};