Skip to main content
Mastra 1.0 is available 🎉 Read announcement

dataset.updateItem()

Added in: @mastra/core@1.4.0

Updates an existing item in the dataset. Only the provided fields are updated. Updating an item creates a new version.

Usage example
Direct link to Usage example

import { Mastra } from "@mastra/core";

const mastra = new Mastra({ /* storage config */ });

const dataset = await mastra.datasets.get({ id: "dataset-id" });

const updated = await dataset.updateItem({
itemId: "item-id",
input: { question: "What is TypeScript?" },
groundTruth: { answer: "A typed superset of JavaScript" },
metadata: { reviewed: true },
});

Parameters
Direct link to Parameters

itemId:

string
ID of the item to update.

input?:

unknown
Updated input data.

groundTruth?:

unknown
Updated ground truth.

metadata?:

Record<string, unknown>
Updated metadata.

Returns
Direct link to Returns

result:

Promise<DatasetItem>
The updated dataset item. See dataset.addItem() for the item shape.
On this page