You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
/** Waits for the database connection to be established
1476
+
*
1448
1477
* @example
1478
+
* ```ts
1449
1479
* await sql.connect();
1480
+
* ```
1450
1481
*/
1451
1482
connect(): Promise<SQL>;
1452
-
/** Closes the database connection with optional timeout in seconds. If timeout is 0, it will close immediately, if is not provided it will wait for all queries to finish before closing.
1483
+
1484
+
/**
1485
+
* Closes the database connection with optional timeout in seconds. If timeout is 0, it will close immediately, if is not provided it will wait for all queries to finish before closing.
/** Closes the database connection with optional timeout in seconds. If timeout is 0, it will close immediately, if is not provided it will wait for all queries to finish before closing.
1458
-
* @alias close
1495
+
1496
+
/**
1497
+
* Closes the database connection with optional timeout in seconds. If timeout is 0, it will close immediately, if is not provided it will wait for all queries to finish before closing.
1498
+
* This is an alias of {@link SQL.close}
1499
+
*
1500
+
* @param options - The options for the close
1501
+
*
1459
1502
* @example
1503
+
* ```ts
1460
1504
* await sql.end({ timeout: 1 });
1505
+
* ```
1461
1506
*/
1462
1507
end(options?: {timeout?: number}): Promise<void>;
1463
-
/** Flushes any pending operations */
1508
+
1509
+
/**
1510
+
* Flushes any pending operations
1511
+
*
1512
+
* @example
1513
+
* ```ts
1514
+
* sql.flush();
1515
+
* ```
1516
+
*/
1464
1517
flush(): void;
1465
-
/** The reserve method pulls out a connection from the pool, and returns a client that wraps the single connection.
1466
-
* This can be used for running queries on an isolated connection.
1467
-
* Calling reserve in a reserved Sql will return a new reserved connection, not the same connection (behavior matches postgres package).
1518
+
1519
+
/**
1520
+
* The reserve method pulls out a connection from the pool, and returns a client that wraps the single connection.
1521
+
* This can be used for running queries on an isolated connection.
1522
+
* Calling reserve in a reserved Sql will return a new reserved connection, not the same connection (behavior matches postgres package).
1523
+
*
1468
1524
* @example
1525
+
* ```ts
1469
1526
* const reserved = await sql.reserve();
1470
1527
* await reserved`select * from users`;
1471
1528
* await reserved.release();
@@ -1476,12 +1533,14 @@ declare module "bun" {
1476
1533
* } finally {
1477
1534
* await reserved.release();
1478
1535
* }
1479
-
* //To make it simpler bun supportsSymbol.dispose and Symbol.asyncDispose
1536
+
*
1537
+
* // Bun supports Symbol.dispose and Symbol.asyncDispose
1480
1538
* {
1481
-
* // always release after context (safer)
1482
-
* using reserved = await sql.reserve()
1483
-
* await reserved`select * from users`
1539
+
* // always release after context (safer)
1540
+
* using reserved = await sql.reserve()
1541
+
* await reserved`select * from users`
1484
1542
* }
1543
+
* ```
1485
1544
*/
1486
1545
reserve(): Promise<ReservedSQL>;
1487
1546
/** Begins a new transaction
@@ -1626,6 +1685,45 @@ declare module "bun" {
1626
1685
1627
1686
[Symbol.asyncDispose](): Promise<any>;
1628
1687
}
1688
+
constSQL: {
1689
+
/**
1690
+
* Creates a new SQL client instance
1691
+
*
1692
+
* @param connectionString - The connection string for the SQL client
1693
+
*
1694
+
* @example
1695
+
* ```ts
1696
+
* const sql = new SQL("postgres://localhost:5432/mydb");
1697
+
* const sql = new SQL(new URL("postgres://localhost:5432/mydb"));
1698
+
* ```
1699
+
*/
1700
+
new(connectionString: string|URL): SQL;
1701
+
1702
+
/**
1703
+
* Creates a new SQL client instance with options
1704
+
*
1705
+
* @param connectionString - The connection string for the SQL client
1706
+
* @param options - The options for the SQL client
1707
+
*
1708
+
* @example
1709
+
* ```ts
1710
+
* const sql = new SQL("postgres://localhost:5432/mydb", { idleTimeout: 1000 });
0 commit comments