File tree Expand file tree Collapse file tree 1 file changed +0
-33
lines changed
Expand file tree Collapse file tree 1 file changed +0
-33
lines changed Original file line number Diff line number Diff line change @@ -117,39 +117,6 @@ export default {
117117}
118118```
119119
120- ### Schema-Aware Type Inference
121-
122- Define your database schema once and get autocomplete for table names, column names, and automatic result type inference:
123-
124- ``` typescript
125- import { D1QB } from ' workers-qb'
126-
127- // Define your schema
128- type Schema = {
129- employees: {
130- id: number
131- name: string
132- role: string
133- active: boolean
134- }
135- }
136-
137- // Initialize with schema type
138- const qb = new D1QB <Schema >(env .DB )
139-
140- // Get full autocomplete and type inference
141- const employees = await qb .fetchAll ({
142- tableName: ' employees' , // Autocomplete: 'employees'
143- fields: [' id' , ' name' ], // Autocomplete: 'id' | 'name' | 'role' | 'active'
144- orderBy: { name: ' ASC' }, // Keys autocomplete to column names
145- }).execute ()
146-
147- // Result type is automatically inferred as { id: number; name: string }[]
148- employees .results ?.forEach (emp => {
149- console .log (emp .id , emp .name ) // Fully typed!
150- })
151- ```
152-
153120### Cloudflare Durable Objects
154121
155122``` typescript
You can’t perform that action at this time.
0 commit comments