@cuillere/postgres v0.13.1
cuillere is an asynchronous execution framework based on generator functions and middlewares.
š§ cuillere is still in early development stage, the API may change at any time.
Why ?
The goal of cuillere is to abstract some inevitable technical complexity (such as managing database transactions) in middlewares, and keep business code as simple and focused as possible.
Usage
In this example we use cuillere to manage the connection to a PostgreSQL database.
const cuillere = require('@cuillere/core')
const { poolMiddleware, transactionMiddleware, queryMiddleware } = require('@cuillere/postgres')
const cllr = cuillere(
poolMiddleware({ /* postgres config */ }), // Manages connection pool
transactionMiddleware(), // Manages transactions
queryMiddleware() // Executes queries
)
const addUserAddress = (userId, address, setDefault) => cllr.execute(function*() {
const res = yield query({
text: `INSERT INTO addresses (userId, street, postalcode, city)
VALUES ($1, $2, $3, $4)
RETURNING *`,
values: [userId, address.street, address.postalCode, address.city]
})
if (setDefault) {
const addressId = res.rows[0].id
yield query({
text: `UPDATE users
SET defaultaddressid = $1
WHERE userid = $2`,
values: [addressId, userId]
})
}
})
Install
yarn add @cuillere/core
Authors
š¤ Valentin Cocaud
- Twitter: @ragorn44
- Github: @EmrysMyrddin
š¤ Nicolas Lepage
- Twitter: @njblepage
- Github: @nlepage
š¤ Contributing
Contributions, issues and feature requests are welcome!Feel free to check issues page.
Show your support
Give a āļø if this project helped you!
š License
Copyright Ā© 2019 Valentin Cocaud. This project is Apache-2.0 licensed.
This README was generated with ā¤ļø by readme-md-generator
2 years ago
2 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago