Skip to content

Commit

Permalink
Add license and update README
Browse files Browse the repository at this point in the history
  • Loading branch information
Andre Azzolini committed May 10, 2018
1 parent 852d655 commit b5f3d78
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 4 deletions.
21 changes: 21 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
The MIT License (MIT)

Copyright (c) 2018 Andre Azzolini and Jekyll contributors

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
14 changes: 10 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# pgr

This module aims to provide a structured and easy way to execute queries against a Postgres DB. It's a good fit if you want more support than using the `pg` module by itself but don't want to use an ORM. Its main features include a tagged template string based query helper and a small wrapper around `pg`'s actual query methods.
This module aims to provide a structured and easy way to execute queries against a Postgres DB. It's a good fit if you want more support than using the [pg](https://github.com/brianc/node-postgres) module by itself but don't want to use an ORM. Its main features include a tagged template string based query helper and a small wrapper around pg's actual query methods.

## Installation

Expand Down Expand Up @@ -73,6 +73,8 @@ WHERE status = 'active'
AND id = '73'
```

> Your variable will get subbed in for the question mark in your expression. If there is no question mark, the variable will be used to test if the expression should be added as-is.
```js
await findUsers({ accountId: 1, roles: ['admin', 'superadmin'] })
```
Expand Down Expand Up @@ -195,13 +197,17 @@ console.log(currentUserEmail) // '[email protected]'
### query.transaction
You can also run multiple queries inside of a transaction:
You can also run multiple queries inside of a transaction:
```js
const result = await query.transaction(async tquery => {
// Inside this function, you should take care to use tquery instead of query
// or you may run into deadlocks.
// Inside this function, you should take care to use tquery instead of query
// or you may run into deadlocks.
// tquery behaves exactly like query (and also has tquery.one)
})
```
## License
MIT

0 comments on commit b5f3d78

Please sign in to comment.