Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@pgtyped/query

Package Overview
Dependencies
Maintainers
1
Versions
44
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@pgtyped/query - npm Package Compare versions

Comparing version 0.1.1 to 0.1.2

4

package.json
{
"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,

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc