Back to Mastra

Reference: DatasetsManager.get() | Datasets

docs/src/content/en/reference/datasets/get.mdx

2025-12-18787 B
Original Source

DatasetsManager.get()

Added in: @mastra/[email protected]

Retrieves an existing dataset by ID. Throws a MastraError if the dataset doesn't exist.

Usage example

typescript
import { Mastra } from '@mastra/core'

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

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

// Now use the dataset
const details = await dataset.getDetails()
console.log(details.name)

Parameters

<PropertiesTable content={[ { name: 'id', type: 'string', description: 'Unique identifier of the dataset.', }, ]} />

Returns

Throws MastraError if the dataset isn't found.

<PropertiesTable content={[ { name: 'result', type: 'Promise<Dataset>', description: 'A Dataset instance.', }, ]} />