Skip to content

Commit

Permalink
chore: remove deprecated D1 dump() (#373)
Browse files Browse the repository at this point in the history
  • Loading branch information
RihanArfan authored Nov 10, 2024
1 parent efb8970 commit 23fba06
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,17 +15,14 @@ export default eventHandler(async (event) => {

// https://developers.cloudflare.com/d1/build-databases/query-databases/
const { command } = await getValidatedRouterParams(event, z.object({
command: z.enum(['first', 'all', 'raw', 'run', 'dump', 'exec', 'batch'])
command: z.enum(['first', 'all', 'raw', 'run', 'exec', 'batch'])
}).parse)
const db = hubDatabase()

if (command === 'exec') {
const { query } = await readValidatedBody(event, statementValidation.pick({ query: true }).parse)
return db.exec(query)
}
if (command === 'dump') {
return db.dump()
}
if (command === 'first') {
const { query, params, colName } = await readValidatedBody(event, z.intersection(
statementValidation,
Expand Down
3 changes: 0 additions & 3 deletions src/runtime/database/server/utils/database.ts
Original file line number Diff line number Diff line change
Expand Up @@ -71,9 +71,6 @@ export function proxyHubDatabase(projectUrl: string, secretKey?: string, headers
body: { query }
}).catch(handleProxyError)
},
async dump() {
return d1API<ArrayBuffer>('/dump').catch(handleProxyError)
},
prepare(query: string) {
const stmt = {
_body: {
Expand Down
4 changes: 3 additions & 1 deletion src/types/database.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import type { D1Database as CFD1Database } from '@cloudflare/workers-types/experimental'

export type D1Database = CFD1Database
type OmitDump<T> = Omit<T, 'dump'>

export type D1Database = OmitDump<CFD1Database>

0 comments on commit 23fba06

Please sign in to comment.