()
| 53 | } |
| 54 | |
| 55 | execute(): { success: true; results: Row[]; meta: { changes: number } } { |
| 56 | this.d1.onStatement?.(this.sql); |
| 57 | const stmt = this.d1.db.prepare(this.sql); |
| 58 | const params = this.params.map(bindable) as never[]; |
| 59 | if (/^\s*(SELECT|WITH)\b/i.test(this.sql)) { |
| 60 | return { success: true, results: stmt.all(...params) as Row[], meta: { changes: 0 } }; |
| 61 | } |
| 62 | const info = stmt.run(...params); |
| 63 | return { success: true, results: [], meta: { changes: Number(info.changes) } }; |
| 64 | } |
| 65 | |
| 66 | async first<T>(): Promise<T | null> { |
| 67 | return (this.execute().results[0] as T | undefined) ?? null; |
no test coverage detected