Skip to content
Start here

Database

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

DatabaseTime 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