Skip to main content

DatasetsManager.list()

Added in: @mastra/core@1.4.0

Lists datasets with pagination and optional filters. Filters are applied at the storage layer, so callers don't need to post-filter results.

Usage example
Direct link to Usage example

import { Mastra } from '@mastra/core'

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

const { datasets, pagination } = await mastra.datasets.list({ page: 0, perPage: 10 })

for (const ds of datasets) {
console.log(`${ds.id}: ${ds.name} (v${ds.version})`)
}

// Filter by target type and name (case-insensitive substring)
const filtered = await mastra.datasets.list({
page: 0,
perPage: 20,
filters: { targetType: 'agent', name: 'qa' },
})

// Filter by any-overlap match on target IDs
const forAgents = await mastra.datasets.list({
filters: { targetIds: ['agent-a', 'agent-b'] },
})

Parameters
Direct link to Parameters

page?:

number
Page number. Defaults to 0.

perPage?:

number
Number of datasets per page. Defaults to 20.

filters?:

object
Optional filters applied at the storage layer.
object

organizationId?:

string
Tenancy filter: restrict to datasets in this organization.

projectId?:

string
Tenancy filter: restrict to datasets in this project.

candidateKey?:

string
Restrict to datasets belonging to this candidate key.

candidateId?:

string
Restrict to datasets belonging to this candidate ID.

targetType?:

'agent' | 'workflow' | 'scorer' | 'processor'
Restrict to datasets targeting this component type.

targetIds?:

string[]
Restrict to datasets whose targetIds intersect this list (any-overlap match). Empty array is treated as no filter.

name?:

string
Case-insensitive substring match on dataset name. Empty string is treated as no filter.

Returns
Direct link to Returns

result:

Promise<object>
Paginated dataset list.
object

datasets:

DatasetRecord[]
Array of dataset records. See dataset.getDetails() for the record shape.

pagination:

PaginationInfo
Pagination metadata with total, page, perPage, and hasMore.
On this page