diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..18ca363 --- /dev/null +++ b/LICENSE @@ -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. diff --git a/README.md b/README.md index 28384a4..a8f1d0a 100644 --- a/README.md +++ b/README.md @@ -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 @@ -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'] }) ``` @@ -195,13 +197,17 @@ console.log(currentUserEmail) // 'apazzolini@test.test' ### 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