UNPKG

cloudflare

Version:

The official TypeScript library for the Cloudflare API

47 lines 2.01 kB
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. import { APIResource } from 'cloudflare/resource'; import * as DatabaseAPI from 'cloudflare/resources/d1/database'; import { V4PagePaginationArray } from 'cloudflare/pagination'; export class Database extends APIResource { /** * Returns the created D1 database. */ create(params, options) { const { account_id, ...body } = params; return this._client.post(`/accounts/${account_id}/d1/database`, { body, ...options })._thenUnwrap((obj) => obj.result); } /** * Returns a list of D1 databases. */ list(params, options) { const { account_id, ...query } = params; return this._client.getAPIList(`/accounts/${account_id}/d1/database`, DatabaseListResponsesV4PagePaginationArray, { query, ...options }); } /** * Deletes the specified D1 database. */ delete(accountIdentifier, databaseIdentifier, options) { return this._client.delete(`/accounts/${accountIdentifier}/d1/database/${databaseIdentifier}`, options)._thenUnwrap((obj) => obj.result); } /** * Returns the specified D1 database. */ get(accountIdentifier, databaseIdentifier, options) { return this._client.get(`/accounts/${accountIdentifier}/d1/database/${databaseIdentifier}`, options)._thenUnwrap((obj) => obj.result); } /** * Returns the query result. */ query(accountIdentifier, databaseIdentifier, body, options) { return this._client.post(`/accounts/${accountIdentifier}/d1/database/${databaseIdentifier}/query`, { body, ...options, })._thenUnwrap((obj) => obj.result); } } export class DatabaseListResponsesV4PagePaginationArray extends V4PagePaginationArray { } (function (Database) { Database.DatabaseListResponsesV4PagePaginationArray = DatabaseAPI.DatabaseListResponsesV4PagePaginationArray; })(Database || (Database = {})); //# sourceMappingURL=database.mjs.map