@@ -5426,11 +5426,47 @@ export interface D1ExecResult {
5426
5426
count : number ;
5427
5427
duration : number ;
5428
5428
}
5429
+ export type D1SessionConstraint =
5430
+ // Indicates that the first query should go to the primary, and the rest queries
5431
+ // using the same D1DatabaseSession will go to any replica that is consistent with
5432
+ // the bookmark maintained by the session (returned by the first query).
5433
+ | "first-primary"
5434
+ // Indicates that the first query can go anywhere (primary or replica), and the rest queries
5435
+ // using the same D1DatabaseSession will go to any replica that is consistent with
5436
+ // the bookmark maintained by the session (returned by the first query).
5437
+ | "first-unconstrained" ;
5438
+ export type D1SessionBookmark = string ;
5429
5439
export declare abstract class D1Database {
5430
5440
prepare ( query : string ) : D1PreparedStatement ;
5431
- dump ( ) : Promise < ArrayBuffer > ;
5432
5441
batch < T = unknown > ( statements : D1PreparedStatement [ ] ) : Promise < D1Result < T > [ ] > ;
5433
5442
exec ( query : string ) : Promise < D1ExecResult > ;
5443
+ /**
5444
+ * Creates a new D1 Session anchored at the given constraint or the bookmark.
5445
+ * All queries executed using the created session will have sequential consistency,
5446
+ * meaning that all writes done through the session will be visible in subsequent reads.
5447
+ *
5448
+ * @param constraintOrBookmark Either the session constraint or the explicit bookmark to anchor the created session.
5449
+ */
5450
+ withSession (
5451
+ constraintOrBookmark :
5452
+ | D1SessionBookmark
5453
+ | D1SessionConstraint
5454
+ | null
5455
+ | undefined ,
5456
+ ) : D1DatabaseSession ;
5457
+ /**
5458
+ * @deprecated dump() will be removed soon, only applies to deprecated alpha v1 databases.
5459
+ */
5460
+ dump ( ) : Promise < ArrayBuffer > ;
5461
+ }
5462
+ export declare abstract class D1DatabaseSession {
5463
+ prepare ( query : string ) : D1PreparedStatement ;
5464
+ batch < T = unknown > ( statements : D1PreparedStatement [ ] ) : Promise < D1Result < T > [ ] > ;
5465
+ /**
5466
+ * @returns The latest session bookmark across all executed queries on the session.
5467
+ * If no query has been executed yet, `null` is returned.
5468
+ */
5469
+ getBookmark ( ) : D1SessionBookmark | null ;
5434
5470
}
5435
5471
export declare abstract class D1PreparedStatement {
5436
5472
bind ( ...values : unknown [ ] ) : D1PreparedStatement ;
0 commit comments