Managing datasources

The following methods allow you to fetch information about the available datasources in your account and/or specific information about them.

Listing datasources

The datasources() method returns the list of datasources the used token has access to (any kind of access), SCOPE:READ or SCOPE:APPEND.

const tinyb = tinybird('<token>')
console.log(await tinyb.datasources())

Getting datasource information

The info() returns information for a specific datasource.

const tinyb = tinybird('<token>')
const { datasources, error } = await tinyb.datasources()
if (datasources.length !== 0) {
    const name = datasources[0]['name']
    console.log(await tinyb.datasource(name).info())
} else {
    console.log(error || `you don't have any datasource in you account`)

Getting datasource schema

The schema() returns the schema for a specific datasources. It contains an array called .columns with the name, type and whether the column accepts null values or not (nullable field).

let tinyb = tinybird('<token>')
console.log(await tinyb.datasource(<datasource>).schema())

Deleting a datasource

delete() drops the datasource. This action can’t be undone.

let tinyb = tinybird('<token>')
await tinyb.datasource('<datasource>').delete()