Bubble · Arazzo Workflow

Bubble Search Then Update a Thing

Version 1.0.0

Search a data type for a record matching a constraint and modify the first match.

1 workflow 1 source API 1 provider
View Spec View on GitHub No-CodeApplication PlatformDatabaseWorkflow AutomationPluginsArazzoWorkflows

Provider

bubble

Workflows

search-then-update-thing
Find a record by a field value and modify the first match.
Runs an equality search on a data type, and when at least one record matches it applies a partial update to the first result; otherwise it ends.
2 steps inputs: fields, key, typename, value outputs: matchedId, modifiedId
1
searchThings
searchThings
Search the data type for records where the supplied key equals the supplied value, returning at most one match.
2
modifyThing
modifyThing
Partially update the first matched record. Only the provided fields are changed; all other fields on the record are left intact.

Source API Descriptions

Arazzo Workflow Specification

bubble-search-then-update-thing-workflow.yml Raw ↑
arazzo: 1.0.1
info:
  title: Bubble Search Then Update a Thing
  summary: Search a data type for a record matching a constraint and modify the first match.
  description: >-
    A find-then-act pattern for the Bubble Data API. The workflow searches a
    data type using a single equality constraint, branches on whether a match
    was found, and when one exists it partially updates that first matched
    record with the supplied fields. When no record matches, the flow ends
    without writing. Every step spells out its request inline so the flow can be
    read and executed without opening the underlying OpenAPI description.
  version: 1.0.0
sourceDescriptions:
- name: bubbleDataApi
  url: ../openapi/bubble-data-api-openapi.yml
  type: openapi
workflows:
- workflowId: search-then-update-thing
  summary: Find a record by a field value and modify the first match.
  description: >-
    Runs an equality search on a data type, and when at least one record matches
    it applies a partial update to the first result; otherwise it ends.
  inputs:
    type: object
    required:
    - typename
    - key
    - value
    - fields
    properties:
      typename:
        type: string
        description: Data type name in lowercase with spaces removed.
      key:
        type: string
        description: The field name to match on (e.g. email).
      value:
        type: string
        description: The value the field must equal.
      fields:
        type: object
        description: Map of field name/value pairs to apply to the matched record.
  steps:
  - stepId: searchThings
    description: >-
      Search the data type for records where the supplied key equals the
      supplied value, returning at most one match.
    operationId: searchThings
    parameters:
    - name: typename
      in: path
      value: $inputs.typename
    - name: constraints
      in: query
      value: '[{"key":"$inputs.key","constraint_type":"equals","value":"$inputs.value"}]'
    - name: limit
      in: query
      value: 1
    successCriteria:
    - condition: $statusCode == 200
    outputs:
      matchedId: $response.body#/response/results/0/_id
      remaining: $response.body#/response/remaining
    onSuccess:
    - name: matchFound
      type: goto
      stepId: modifyThing
      criteria:
      - context: $response.body
        condition: $.response.results.length > 0
        type: jsonpath
    - name: noMatch
      type: end
      criteria:
      - context: $response.body
        condition: $.response.results.length == 0
        type: jsonpath
  - stepId: modifyThing
    description: >-
      Partially update the first matched record. Only the provided fields are
      changed; all other fields on the record are left intact.
    operationId: modifyThing
    parameters:
    - name: typename
      in: path
      value: $inputs.typename
    - name: uid
      in: path
      value: $steps.searchThings.outputs.matchedId
    requestBody:
      contentType: application/json
      payload: $inputs.fields
    successCriteria:
    - condition: $statusCode == 204
    outputs:
      modifiedId: $steps.searchThings.outputs.matchedId
  outputs:
    matchedId: $steps.searchThings.outputs.matchedId
    modifiedId: $steps.modifyThing.outputs.modifiedId