Turso.Platform.Databases
Interact with databases in Turso.
A database in Turso. Many functions in this module return a Database
.
List Databases
Arguments for the list
function.
Both group
and parent
are optional. Not providing them will list all databases
for the given organization specified in Turso.Platform.Connection
If provided,
they do the following:
group
will filter the resulting list based on the group name provided.parent
will filter the resulting list to databases whose parent database matches the id of the passed parent database.
Errors that can happen when attempting to list databases.
ListErrorGroupNotFound
happens when, if a group name is provided, that group does not exist.ListHttpError
captures any other HTTP errors.
List databases in your Turso organization.
When successfully, returns an Array Database
of the retrieved databases.
Get a Single Database
Arguments for the retrieve
function.
databaseName
is the name of the database you want to retrieve.
Errors that can happen when attempting to retrieve a database.
RetrieveErrorDatabaseNotFound
happens when the passed database name does not exist in Turso.RetrieveHttpError
captures any other HTTP errors.
Retrieve a specific database by name.
When successful, returns a single Database
record.
Create Databases
Arguments needed to create a database.
group
is the group the created database will be a part of. This group must already be created or else the request will fail.databaseName
is the name of the newly created database. The request will fail if there is already a database of the specified name created.
Results of successfully creating a database with the Turso API.
databaseId
is the newly created databases id in Turso.databaseName
is the name of the newly created database. This will match the name given to thecreate
function.hostname
is a value that can be used to make specific requests to that database using theTurso.Db
module in this package.
Errors that can happen when attempting to create a database.
CreateErrorDatabaseAlreadyExists
happens when you're trying to create a database whose name already existing in Turso for the group you're making the database in.CreateErrorGroupNotFound
happens when the group you're trying to create the database for does not exist in the organization.CreateHttpError
captures any other HTTP errors.
Create a new Turso database.
Delete Databases
Arguments for the delete
function.
databaseName
is the name of the database you want to delete.
Results of successfully deleting a database.
databaseName
is the name of the deleted database. This should match the name given in thedelete
function.
Errors that can happen when attempting to delete a database.
DeleteErrorDatabaseNotFound
happens when the passed database name does not exist yet in Turso.DeleteHttpError
captures any other HTTP errors.
Delete a database in Turso.
Create Database Tokens
Create tokens for a specific database in Turso. These tokens can be used
to query databases with the Turso.Db
module.
Arguments needed to create a database token.
databaseName
is the name of the database you want to create the token for.expiration
field is a string representing when the token expires. This must resemble the following format:2w1d30m
. If not provided, the token will never expire.authorization
value specifies what type of actions the token will be able to take on the database. The default value isFullAccess
. See theTokenAuthorization
type for more options.permissions
record has one field:readAttachDatabases
. Providing an array of database ids which this token is allowed to attach to a SQL statement with theATTACH
keyword. If not required, an empty array ([]
) can be provided as the value.
Represents the type of access a token is allowed to have for the database.
FullAccess
allows reading and writing data to the database.ReadOnly
only allows queries to read data from the database.
Results of successfully creating token for a database.
jwt
is aString
representing the created JWT (JavaScipt Web Token).
Create a token for operating on a database in Turso.
Invalidate Database Tokens
Arguments needed to invalidate all tokens for a database.
databaseName
is the database you want to invalid the tokens for.
Errors that can happen when attempting to invalidate a databases tokens.
InvalidateTokensErrorDatabaseNotFound
happens when the passed database name does not exist yet in Turso.InvalidateTokensHttpError
captures any other HTTP errors.
Invalidate all tokens for the given database name.
When successfull, will invalidate all tokens for the given database, but returns no values.
Get Database Usage
Arguments for the usage
function.
databaseName
is the name of the database you want to get usage information forfrom
is the first date you want to get usage for.to
is the last date you want to get usage for.
Both from
and to
must be ISO 8601 strings.
The specific stats for an individual database.
The results of getting usage information for a database.
databaseId
is the id of the database you're getting usage fortotaUsage
is sum of all of theUsageStats
from all instances of the given database.instances
is the usage for each specific instance of the database.
Errors that can happen when attempting to retrieve usage information for a database.
UsageErrorInvalidQueryParameter
happens when the passedfrom
orto
values are not valid ISO 8601 strings.UsageErrorDatabaseNotFound
happens when the passed database name does not exist yet in Turso.RetrieveHttpError
captures any other HTTP errors.
Get the usage information for a given database.
Get Database Stats
Arguments for the stats
function.
databaseName
is the name of the database you want to get stats for.
The results of getting stats for a database.
topQueries
is an array of the queries who have done the most reading and writing of rows for the database.
Errors that can happen when attempting to retrieve stats for a database.
StatsErrorDatabaseNotFound
happens when the passed database name does not exist in Turso.StatsHttpError
captures any other HTTP errors.
Get stats for a given database.