One round trip: the statements run in order, in one implicit transaction.
(statements: D1PreparedStatement[])
| 512 | |
| 513 | /** One round trip: the statements run in order, in one implicit transaction. */ |
| 514 | async batch(statements: D1PreparedStatement[]): Promise<D1Result[]> { |
| 515 | for (let attempt = 0; ; attempt++) { |
| 516 | this.queries++; |
| 517 | try { |
| 518 | const results = await this.env.DB.batch(statements); |
| 519 | const spent = results.reduce((total, r) => total + (r.meta?.duration ?? 0), 0); |
| 520 | await pacing.sleep(Math.min(REST_MAX_MS, Math.max(REST_MIN_MS, REST_FACTOR * spent))); |
| 521 | return results; |
| 522 | } catch (err) { |
| 523 | const wait = RETRY_WAITS_MS[attempt]; |
| 524 | if (wait === undefined || !RETRYABLE.test(String(err))) throw err; |
| 525 | this.retries++; |
| 526 | await pacing.sleep(wait); |
| 527 | } |
| 528 | } |
| 529 | } |
| 530 | |
| 531 | /** The first row of one statement, or null. */ |
| 532 | async first<T>(statement: D1PreparedStatement): Promise<T | null> { |
no outgoing calls
no test coverage detected