Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ export default {
key: "data_stores-delete-single-record",
name: "Delete a single record",
description: "Delete a single record in your [Pipedream Data Store](https://pipedream.com/data-stores/).",
version: "0.0.9",
version: "0.0.10",
type: "action",
props: {
app,
Expand All @@ -31,9 +31,11 @@ export default {
if (record) {
await this.dataStore.delete(this.key);
$.export("$summary", `Successfully deleted the record for key, \`${this.key}\`.`);
$.export("key", this.key);
return record;
}

$.export("$summary", `No record found for key, \`${this.key}\`. No data was deleted.`);
$.export("key", this.key);
},
};
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ export default {
key: "data_stores-get-record-or-create",
name: "Get record (or create one if not found)",
description: "Get a single record in your [Pipedream Data Store](https://pipedream.com/data-stores/) or create one if it doesn't exist.",
version: "0.0.11",
version: "0.0.12",
type: "action",
props: {
app,
Expand Down Expand Up @@ -46,37 +46,41 @@ export default {
},
async run({ $ }) {
const record = await this.dataStore.get(this.key);
let summary, response;

if (record !== undefined) {
$.export("$summary", `Found data for the key, \`${this.key}\`.`);
return record;
summary = `Found data for the key, \`${this.key}\`.`;
response = record;
}

if (!this.app.shouldAddRecord(this.addRecordIfNotFound)) {
$.export("$summary", `No data found for key, \`${this.key}\`.`);
return;
else if (!this.app.shouldAddRecord(this.addRecordIfNotFound)) {
summary = `No data found for key, \`${this.key}\`.`;
}
else {
const parsedValue = this.app.parseValue(this.value);

const parsedValue = this.app.parseValue(this.value);
if (this.ttl) {
await this.dataStore.set(this.key, parsedValue, {
ttl: this.ttl,
});
summary = `Successfully added a new record with the key, \`${this.key}\` (expires in ${this.app.formatTtl(this.ttl)}).`;
} else {
await this.dataStore.set(this.key, parsedValue);
summary = `Successfully added a new record with the key, \`${this.key}\`.`;
}

if (this.ttl) {
await this.dataStore.set(this.key, parsedValue, {
ttl: this.ttl,
});
$.export("$summary", `Successfully added a new record with the key, \`${this.key}\` (expires in ${this.app.formatTtl(this.ttl)}).`);
} else {
await this.dataStore.set(this.key, parsedValue);
$.export("$summary", `Successfully added a new record with the key, \`${this.key}\`.`);
}
// Include TTL information in the return value if it was set
if (this.ttl) {
return {
value: parsedValue,
ttl: this.ttl,
};
}
Comment on lines +72 to +77

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks like it returns too early, and therefore doesn't export the summary or key.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@binarymonkey84 Thanks for catching that. I created an update to fix it here: #15913


// Include TTL information in the return value if it was set
if (this.ttl) {
return {
value: parsedValue,
ttl: this.ttl,
};
response = parsedValue;
}

return parsedValue;
$.export("$summary", summary);
$.export("key", this.key);
return response;
},
};
2 changes: 1 addition & 1 deletion components/data_stores/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@pipedream/data_stores",
"version": "0.1.6",
"version": "0.1.7",
"description": "Pipedream Data Stores Components",
"main": "data_stores.app.js",
"keywords": [
Expand Down
Loading