Skip to content

Commit 26caf76

Browse files
committed
export key
1 parent 006c9ee commit 26caf76

File tree

3 files changed

+32
-26
lines changed

3 files changed

+32
-26
lines changed

components/data_stores/actions/delete-single-record/delete-single-record.mjs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ export default {
44
key: "data_stores-delete-single-record",
55
name: "Delete a single record",
66
description: "Delete a single record in your [Pipedream Data Store](https://pipedream.com/data-stores/).",
7-
version: "0.0.9",
7+
version: "0.0.10",
88
type: "action",
99
props: {
1010
app,
@@ -31,9 +31,11 @@ export default {
3131
if (record) {
3232
await this.dataStore.delete(this.key);
3333
$.export("$summary", `Successfully deleted the record for key, \`${this.key}\`.`);
34+
$.export("key", this.key);
3435
return record;
3536
}
3637

3738
$.export("$summary", `No record found for key, \`${this.key}\`. No data was deleted.`);
39+
$.export("key", this.key);
3840
},
3941
};

components/data_stores/actions/get-record-or-create/get-record-or-create.mjs

Lines changed: 28 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ export default {
44
key: "data_stores-get-record-or-create",
55
name: "Get record (or create one if not found)",
66
description: "Get a single record in your [Pipedream Data Store](https://pipedream.com/data-stores/) or create one if it doesn't exist.",
7-
version: "0.0.11",
7+
version: "0.0.12",
88
type: "action",
99
props: {
1010
app,
@@ -46,37 +46,41 @@ export default {
4646
},
4747
async run({ $ }) {
4848
const record = await this.dataStore.get(this.key);
49+
let summary, response;
4950

5051
if (record !== undefined) {
51-
$.export("$summary", `Found data for the key, \`${this.key}\`.`);
52-
return record;
52+
summary = `Found data for the key, \`${this.key}\`.`;
53+
response = record;
5354
}
54-
55-
if (!this.app.shouldAddRecord(this.addRecordIfNotFound)) {
56-
$.export("$summary", `No data found for key, \`${this.key}\`.`);
57-
return;
55+
else if (!this.app.shouldAddRecord(this.addRecordIfNotFound)) {
56+
summary = `No data found for key, \`${this.key}\`.`;
5857
}
58+
else {
59+
const parsedValue = this.app.parseValue(this.value);
5960

60-
const parsedValue = this.app.parseValue(this.value);
61+
if (this.ttl) {
62+
await this.dataStore.set(this.key, parsedValue, {
63+
ttl: this.ttl,
64+
});
65+
summary = `Successfully added a new record with the key, \`${this.key}\` (expires in ${this.app.formatTtl(this.ttl)}).`;
66+
} else {
67+
await this.dataStore.set(this.key, parsedValue);
68+
summary = `Successfully added a new record with the key, \`${this.key}\`.`;
69+
}
6170

62-
if (this.ttl) {
63-
await this.dataStore.set(this.key, parsedValue, {
64-
ttl: this.ttl,
65-
});
66-
$.export("$summary", `Successfully added a new record with the key, \`${this.key}\` (expires in ${this.app.formatTtl(this.ttl)}).`);
67-
} else {
68-
await this.dataStore.set(this.key, parsedValue);
69-
$.export("$summary", `Successfully added a new record with the key, \`${this.key}\`.`);
70-
}
71+
// Include TTL information in the return value if it was set
72+
if (this.ttl) {
73+
return {
74+
value: parsedValue,
75+
ttl: this.ttl,
76+
};
77+
}
7178

72-
// Include TTL information in the return value if it was set
73-
if (this.ttl) {
74-
return {
75-
value: parsedValue,
76-
ttl: this.ttl,
77-
};
79+
response = parsedValue;
7880
}
7981

80-
return parsedValue;
82+
$.export("$summary", summary);
83+
$.export("key", this.key);
84+
return response;
8185
},
8286
};

components/data_stores/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@pipedream/data_stores",
3-
"version": "0.1.6",
3+
"version": "0.1.7",
44
"description": "Pipedream Data Stores Components",
55
"main": "data_stores.app.js",
66
"keywords": [

0 commit comments

Comments
 (0)