AI bulk transforms (NL to JS)
Describe a per-item change and Tablyne generates a JavaScript transform, dry-run previewed before it writes.
Describe how each item should change in plain language, and Tablyne writes the JavaScript transform for you — then shows a before/after preview before anything is written.
Where to find it
AI transforms are part of bulk operations. Open the bulk panel, scope the rows you want to touch with the query builder, and choose the Transform action. If you’ve connected a provider in AI setup, an AI prompt row appears above the code editor.
If no provider is configured, the panel shows a shortcut to Settings → AI.
From plain language to JS
Type the per-item change you want:
add a total field equal to price times quantity
uppercase the country code
remove the deprecated legacy_id attribute
Press Enter or click the generate button. Tablyne sends your prompt plus the table’s attribute names (no item data — see AI setup) and gets back a single JavaScript expression that takes an item and returns the transformed item. The result drops straight into the code editor, where you can read and edit it.
The generated code is an expression, not a function body, and uses spread to preserve untouched fields:
({...item, total: item.price * item.qty})
Runs locally via new Function
The transform executes entirely on your machine. Tablyne compiles the expression with new Function("item", …) in strict mode and runs it per item in the app — the code is never sent anywhere to execute. Each matching row is passed in as a plain JavaScript object named item, and whatever the expression returns becomes the new item.
Because it’s real JavaScript, you can do anything an expression allows:
({...item, name: item.name.trim(), updatedAt: Date.now()})
A row that throws or returns nothing is skipped, not written — so a transform that fails on a few odd items won’t corrupt them.
Dry-run preview first
Before writing anything, click Preview. Tablyne counts the affected rows and runs the transform against a small sample, showing a per-field before → after diff:
order#4821 total: ∅ → 1250
order#4822 total: ∅ → 90
Fields that don’t change are reported as unchanged, and any row whose expression errors shows the error message instead of a diff. This lets you confirm the transform does what you intended on real data before committing to it.
Danger confirmation before writing
Executing a transform writes to your table, so it’s gated behind an explicit confirmation. When you click Execute, Tablyne asks you to confirm a destructive action — showing the operation, the affected count, and the scope (the query/scan you defined) — and you confirm against the table name. Only then does the write loop run, batching results back to DynamoDB page by page with live progress (written / scanned / skipped). You can abort mid-run.
Idempotency
The bulk panel surfaces a warning to write idempotent transforms, and the AI is prompted to make them idempotent where possible. This matters because a transform runs over every matching row, and you may run it more than once (e.g. after widening the scope). An idempotent transform produces the same result no matter how many times it’s applied:
// idempotent — re-running yields the same value
({...item, slug: item.title.toLowerCase().replace(/\s+/g, '-')})
// NOT idempotent — appends every run
({...item, tags: [...item.tags, 'migrated']})
Prefer assignments that compute from the source fields rather than accumulating. When in doubt, scope tightly (e.g. only items missing the new field) and use the dry-run to confirm a second pass would be a no-op.
Workflow at a glance
| Step | Action |
|---|---|
| 1 | Scope the rows with the query builder |
| 2 | Choose Transform, describe the change, generate JS |
| 3 | Edit the generated expression if needed |
| 4 | Preview — review the before/after diff on a sample |
| 5 | Execute — confirm the danger prompt, watch progress |