Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions docs/mysql-options.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,17 @@ sidebar_label: Connection Options
- `queueTimeoutMilliseconds` (`number`, default: `60_000`ms) - number of milliseconds to wait for a connection from the connection pool before throwing a timeout error
- `acquireLockTimeoutMilliseconds` (`number`, default: `60_000`ms) - Number of milliseconds to wait for a lock on a connection/transaction. This is helpful for catching cases where you have accidentally attempted to query a connection within a transaction that is on that connection, or attempted to query an outer transaction within a nested transaction

## Example

```
const db = createConnectionPool({
connectionString: 'mysql://test-user:password@localhost:3306/test-db',
tinyIntMode: 'boolean',
dateMode: 'string',
dateTimeMode: 'string',
})
```

## Event Handlers

For more detail on how to use event handlers, see [Logging & Debugging](pg-guide-logging.md) - install `@databases/pg` and run your first query
Expand Down
11 changes: 11 additions & 0 deletions docs/pg-options.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,17 @@ sidebar_label: Connection Options
- `queueTimeoutMilliseconds` (`number`, default: `60_000`ms) - number of milliseconds to wait for a connection from the connection pool before throwing a timeout error
- `acquireLockTimeoutMilliseconds` (`number`, default: `60_000`ms) - Number of milliseconds to wait for a lock on a connection/transaction. This is helpful for catching cases where you have accidentally attempted to query a connection within a transaction that is on that connection, or attempted to query an outer transaction within a nested transaction

## Example

```
const db = createConnectionPool({
connectionString: 'postgres://test-user@localhost:5432/test-db',
tinyIntMode: 'boolean',
dateMode: 'string',
dateTimeMode: 'string',
})
```

## Event Handlers

For more detail on how to use event handlers, see [Logging & Debugging](pg-guide-logging.md) - install `@databases/pg` and run your first query
Expand Down
10 changes: 9 additions & 1 deletion docs/sql.md
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,14 @@ db.query(sql`SELECT ${fieldName} FROM users AS u;`);
// => {text: 'SELECT "u"."id" FROM users AS u;', values: []}
```

Or dynamically include a table name.

```ts
const tableName = 'users';
db.query(sql`SELECT * FROM ${sql.ident(tableName)}`);
// => {text: 'SELECT * FROM users;', values: []}
```

### `sql.value(val)`

`sql.value(val)` acts as a shorthand for `` sql`${val}` ``. It takes a value, and represents it with a placeholder in the resulting query.
Expand All @@ -69,7 +77,7 @@ db.query(sql`SELECT * FROM users WHERE id=${id};`);

### `sql.join(arrayOfFragments, delimiter)`

Joins an array of SQLQuery values using the delimiter (which is treated as a raw SQL string). It properly handles joining the array of values and ensuring that the placeholders match up.
Joins an array of SQLQuery values using the delimiter (which defaults to an empty string). It properly handles joining the array of values and ensuring that the placeholders match up.

```ts
const arrayOfSqlFields = ['a', 'b', 'c', 'd'].map((n) => sql.identifier(n));
Expand Down