Skip to content
Start here

D1

ModelsExpand Collapse
type D1 struct{…}

The details of the D1 database.

CreatedAt Timeoptional

Specifies the timestamp the resource was created as an ISO8601 string.

formatdate-time
FileSize float64optional

The D1 database's size, in bytes.

Jurisdiction D1Jurisdictionoptional

Specify the location to restrict the D1 database to run and store data. If this option is present, the location hint is ignored.

One of the following:
const D1JurisdictionEu D1Jurisdiction = "eu"
const D1JurisdictionFedramp D1Jurisdiction = "fedramp"
Name stringoptional

D1 database name.

NumTables float64optional
ReadReplication D1ReadReplicationoptional

Configuration for D1 read replication.

Mode D1ReadReplicationMode

The read replication mode for the database. Use 'auto' to create replicas and allow D1 automatically place them around the world, or 'disabled' to not use any database replicas (it can take a few hours for all replicas to be deleted).

One of the following:
const D1ReadReplicationModeAuto D1ReadReplicationMode = "auto"
const D1ReadReplicationModeDisabled D1ReadReplicationMode = "disabled"
UUID stringoptional

D1 database identifier (UUID).

Version stringoptional

D1Database

List D1 Databases
client.D1.Database.List(ctx, params) (*V4PagePaginationArray[DatabaseListResponse], error)
GET/accounts/{account_id}/d1/database
Get D1 Database
client.D1.Database.Get(ctx, databaseID, query) (*D1, error)
GET/accounts/{account_id}/d1/database/{database_id}
Create D1 Database
client.D1.Database.New(ctx, params) (*D1, error)
POST/accounts/{account_id}/d1/database
Update D1 Database
client.D1.Database.Update(ctx, databaseID, params) (*D1, error)
PUT/accounts/{account_id}/d1/database/{database_id}
Update D1 Database partially
client.D1.Database.Edit(ctx, databaseID, params) (*D1, error)
PATCH/accounts/{account_id}/d1/database/{database_id}
Delete D1 Database
client.D1.Database.Delete(ctx, databaseID, body) (*DatabaseDeleteResponse, error)
DELETE/accounts/{account_id}/d1/database/{database_id}
Query D1 Database
client.D1.Database.Query(ctx, databaseID, params) (*SinglePage[QueryResult], error)
POST/accounts/{account_id}/d1/database/{database_id}/query
Raw D1 Database query
client.D1.Database.Raw(ctx, databaseID, params) (*SinglePage[DatabaseRawResponse], error)
POST/accounts/{account_id}/d1/database/{database_id}/raw
Export D1 Database as SQL
client.D1.Database.Export(ctx, databaseID, params) (*DatabaseExportResponse, error)
POST/accounts/{account_id}/d1/database/{database_id}/export
Import SQL into your D1 Database
client.D1.Database.Import(ctx, databaseID, params) (*DatabaseImportResponse, error)
POST/accounts/{account_id}/d1/database/{database_id}/import
ModelsExpand Collapse
type QueryResult struct{…}
Meta QueryResultMetaoptional
ChangedDB booloptional

Denotes if the database has been altered in some way, like deleting rows.

Changes float64optional

Rough indication of how many rows were modified by the query, as provided by SQLite's sqlite3_total_changes().

Duration float64optional

The duration of the SQL query execution inside the database. Does not include any network communication.

LastRowID float64optional

The row ID of the last inserted row in a table with an INTEGER PRIMARY KEY as provided by SQLite. Tables created with WITHOUT ROWID do not populate this.

RowsRead float64optional

Number of rows read during the SQL query execution, including indices (not all rows are necessarily returned).

RowsWritten float64optional

Number of rows written during the SQL query execution, including indices.

ServedByColo stringoptional

The three letters airport code of the colo that handled the query.

ServedByPrimary booloptional

Denotes if the query has been handled by the database primary instance.

ServedByRegion QueryResultMetaServedByRegionoptional

Region location hint of the database instance that handled the query.

One of the following:
const QueryResultMetaServedByRegionWnam QueryResultMetaServedByRegion = "WNAM"
const QueryResultMetaServedByRegionEnam QueryResultMetaServedByRegion = "ENAM"
const QueryResultMetaServedByRegionWeur QueryResultMetaServedByRegion = "WEUR"
const QueryResultMetaServedByRegionEeur QueryResultMetaServedByRegion = "EEUR"
const QueryResultMetaServedByRegionApac QueryResultMetaServedByRegion = "APAC"
const QueryResultMetaServedByRegionOc QueryResultMetaServedByRegion = "OC"
SizeAfter float64optional

Size of the database after the query committed, in bytes.

Timings QueryResultMetaTimingsoptional

Various durations for the query.

SqlDurationMs float64optional

The duration of the SQL query execution inside the database. Does not include any network communication.

Results []unknownoptional
Success booloptional

D1DatabaseTime Travel

Get D1 database bookmark
client.D1.Database.TimeTravel.GetBookmark(ctx, databaseID, params) (*DatabaseTimeTravelGetBookmarkResponse, error)
GET/accounts/{account_id}/d1/database/{database_id}/time_travel/bookmark
Restore D1 Database to a bookmark or point in time
client.D1.Database.TimeTravel.Restore(ctx, databaseID, params) (*DatabaseTimeTravelRestoreResponse, error)
POST/accounts/{account_id}/d1/database/{database_id}/time_travel/restore