Skip to content
Open
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
25 changes: 25 additions & 0 deletions src/content/docs/concepts/canvas-memory.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,31 @@ SuperPlane provides five memory components:

See the [Components](/components/core) reference for field-level configuration.

## Reading memory in expressions

You can query memory directly in any expression field using `memory.find()` and `memory.findFirst()`, without adding a Read Memory node to the canvas.

| Function | Returns |
| -------- | ------- |
| `memory.find(namespace, matches)` | All records in `namespace` whose fields contain `matches`. |
| `memory.findFirst(namespace, matches)` | The first matching record, or `nil` if none. |

`matches` is a JSON object — a record matches if its fields include all key-value pairs in the object.

**Example — read a machine's status inline:**

```
{{memory.findFirst("machines", {"sandbox_id": $['Start'].data.sandbox_id}).status}}
```

**Example — check whether any machine is idle:**

```
memory.find("machines", {"status": "idle"}) != nil
```

Use `memory.findFirst()` when you expect a unique key and want a single value. Use `memory.find()` when you need all matches (for example, to pass the array to a downstream node or iterate over it).

## Manual memory entry and edits

You don't have to rely solely on workflows to manage memory. You can manually view, add, edit, and delete records directly from the SuperPlane UI.
Expand Down
2 changes: 2 additions & 0 deletions src/content/docs/concepts/expression-functions.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ This page lists every function available in SuperPlane expressions. For an intro
| `root()` | Root payload that started the run | `root().data.ref` |
| `previous()` | Immediate upstream node's payload | `previous().data.status` |
| `previous(n)` | Walk n levels upstream | `previous(2).data.version` |
| `memory.find(namespace, matches)` | All [memory](/concepts/canvas-memory) records in `namespace` matching `matches` | `memory.find("machines", {"sandbox_id": "12121"})` |
| `memory.findFirst(namespace, matches)` | First matching [memory](/concepts/canvas-memory) record, or `nil` | `memory.findFirst("machines", {"creator": "igor"}).sandbox_id` |

---

Expand Down
14 changes: 14 additions & 0 deletions src/content/docs/concepts/expressions.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,20 @@ Every entry also includes a **`.config`** property — the node's resolved confi

`previous()` is not available when a node has multiple inputs (e.g. after a Merge). Use `$['Node Name']` instead.

### `memory`

The `memory` namespace lets you query [canvas memory](/concepts/canvas-memory) records directly in any expression, without adding a Read Memory node.

| Function | Returns |
| -------- | ------- |
| `memory.find(namespace, matches)` | All records in `namespace` whose fields contain `matches`. |
| `memory.findFirst(namespace, matches)` | The first matching record, or `nil` if none. |

```
{{memory.find("machines", {"sandbox_id": "12121"})}}
{{memory.findFirst("machines", {"creator": "igor"}).sandbox_id}}
```

---

## Syntax: text fields vs conditions
Expand Down