# ts-sqlx
[](LICENSE-MIT)
[](https://www.npmjs.com/package/ts-sqlx)
Typescript SQLx compile-time checked queries without a DSL. see main [package](https://github.com/nathanfaucett/ts-sqlx)
```typescript
import { sqlx, type SqlxString } from 'ts-sqlx';
import Pool from 'pg-pool';
const pool = new Pool();
function query<P extends unknown[], R = unknown>(
query: SqlxString<P, R>,
...params: P
): Promise<R[]> {
return pool.query(query, params).then((result) => result.rows);
}
const post = await query(sqlx('select p.* from posts p where p.id = $1;'), 1);
console.log(post);
```
See [example](https://github.com/nathanfaucett/ts-sqlx/tree/main/node/example) for a "full" project example