@pgtyped/query
Advanced tools
Comparing version 0.1.1 to 0.1.2
{ | ||
"name": "@pgtyped/query", | ||
"version": "0.1.1", | ||
"version": "0.1.2", | ||
"main": "lib/index.js", | ||
@@ -28,3 +28,3 @@ "license": "MIT", | ||
}, | ||
"gitHead": "c63fe1068246f5de64531d2d34b1eabed2d14a44" | ||
"gitHead": "180335a7b36511977afe795c10b589d62d727109" | ||
} |
@@ -1,4 +0,25 @@ | ||
### PgTyped Query | ||
## @pgtyped/query | ||
This package provides the `sql` tagged template. | ||
The `sql` tagged template requires two generics: `<TResult, TParam>`. | ||
`TResult` is the query result type and `TParam` is the query parameters type. Both types should be imported from query types files generated by `pgtyped`. | ||
To run a query defined with the `sql` tagged template, call the `sql.run` method. | ||
The `sql.run` method automatically enforces correct input `TParams` and output `TResult` types. | ||
```js | ||
public run: ( | ||
params: TParams, | ||
dbConnection: IDatabaseConnection, | ||
) => Promise<TResult[]>; | ||
``` | ||
Here `dbConnection` is any object that satisifies the `IDatabaseConnection` interface. It is used to actually send the query to the DB for execution. | ||
``` | ||
interface IDatabaseConnection { | ||
query: (query: string, bindings: any[]) => Promise<{ rows: any[] }>; | ||
} | ||
``` | ||
This is usually the `client` object created with [node-postgres](https://github.com/brianc/node-postgres), but can be any other connection of your choice. | ||
This package is part of the pgtyped project. | ||
Refer to root [README](https://github.com/adelsz/pgtyped) for details. |
@@ -11,3 +11,3 @@ import processQuery, { | ||
export class TaggedQuery<TResult, TParams> { | ||
public run: <X>( | ||
public run: ( | ||
params: TParams, | ||
@@ -14,0 +14,0 @@ dbConnection: IDatabaseConnection, |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
79592
26