← Data Stores

Get record (or create one if not found) with Data Stores API

Pipedream makes it easy to connect APIs for Data Stores and 800+ other apps remarkably fast.

Trigger workflow on
HTTP requests, schedules and app events
Next, do this
Get record (or create one if not found) with the Data Stores API
No credit card required
Into to Pipedream
Watch us build a workflow
Watch us build a workflow
7 min
Watch now ➜
Trusted by 250,000+ developers from startups to Fortune 500 companies:
Trusted by 250,000+ developers from startups to Fortune 500 companies

Developers Pipedream

Getting Started

Create a workflow to Get record (or create one if not found) with the Data Stores API. When you configure and deploy the workflow, it will run on Pipedream's servers 24x7 for free.

  1. Configure the Get record (or create one if not found) action
    1. Connect your Data Stores account
    2. Configure Data Store
    3. Select a Key
    4. Optional- Select a Create a new record if the key is not found?
  2. Select a trigger to run your workflow on HTTP requests, schedules or app events
  3. Deploy the workflow
  4. Send a test event to validate your setup
  5. Turn on the trigger

Details

This is a pre-built, open source component from Pipedream's GitHub repo. The component is developed by Pipedream and the community, and verified and maintained by Pipedream.

To contribute an update to an existing component or create a new component, create a PR on GitHub. If you're new to Pipedream component development, you can start with quickstarts for trigger span and action development, and then review the component API reference.

Get record (or create one if not found) on Data Stores
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.8
Key:data_stores-get-record-or-create

Code

import app from "../../data_stores.app.mjs";

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.8",
  type: "action",
  props: {
    app,
    dataStore: {
      propDefinition: [
        app,
        "dataStore",
      ],
    },
    key: {
      propDefinition: [
        app,
        "key",
        ({ dataStore }) => ({
          dataStore,
        }),
      ],
      description: "Select the key for the data you'd like to retrieve, or enter one manually.",
    },
    addRecordIfNotFound: {
      propDefinition: [
        app,
        "addRecordIfNotFound",
      ],
    },
  },
  async additionalProps() {
    const props = {};
    if (this.app.shouldAddRecord(this.addRecordIfNotFound)) {
      props.value = app.propDefinitions.value;
    }
    return props;
  },
  async run({ $ }) {
    const record = await this.dataStore.get(this.key);

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

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

    const parsedValue = this.app.parseValue(this.value);
    await this.dataStore.set(this.key, parsedValue);
    $.export("$summary", `Successfully added a new record with the key, \`${this.key}\`.`);
    return parsedValue;
  },
};

Configuration

This component may be configured based on the props defined in the component code. Pipedream automatically prompts for input values in the UI and CLI.
LabelPropTypeDescription
Data StoresappappThis component uses the Data Stores app.
Data StoredataStoredata_store

Select an existing Data Store or create a new one.

KeykeystringSelect a value from the drop down menu.
Create a new record if the key is not found?addRecordIfNotFoundstringSelect a value from the drop down menu:YesNo

Authentication

The Data Stores API does not require authentication.

About Data Stores

Use Pipedream Data Stores to manage state throughout your workflows.