项目作者: cuillerejs

项目描述 :
CuillereJS is an extensible asynchronous execution framework based on generator functions.
高级语言: TypeScript
项目地址: git://github.com/cuillerejs/cuillere.git
创建时间: 2019-06-09T08:33:00Z
项目社区:https://github.com/cuillerejs/cuillere

开源协议:Apache License 2.0

下载






Welcome to CuillereJS 🥄

@cuillere/core"">Version
License: Apache-2.0

CuillereJS is an extensible asynchronous execution framework based on generator functions.

🚧 CuillereJS is still experimental, APIs may change at any time.

Why ?

The goal of CuillereJS is to abstract some inevitable technical complexity (such as managing database transactions) in plugins, and keep business code as simple and focused as possible.

Usage

In this example we use CuillereJS to manage the connection to a PostgreSQL database.

  1. const cuillere = require('@cuillere/core')
  2. const { poolPlugin, transactionPlugin, queryPlugin } = require('@cuillere/postgres')
  3. const cllr = cuillere(
  4. poolPlugin({ /* postgres config */ }), // Manages connection pool
  5. transactionPlugin(), // Manages transactions
  6. queryPlugin() // Executes queries
  7. )
  8. const addUserAddress = (userId, address, setDefault) => cllr.call(function*() {
  9. const res = yield query({
  10. text: `INSERT INTO addresses (userId, street, postalcode, city)
  11. VALUES ($1, $2, $3, $4)
  12. RETURNING *`,
  13. values: [userId, address.street, address.postalCode, address.city]
  14. })
  15. if (setDefault) {
  16. const addressId = res.rows[0].id
  17. yield query({
  18. text: `UPDATE users
  19. SET defaultaddressid = $1
  20. WHERE userid = $2`,
  21. values: [addressId, userId]
  22. })
  23. }
  24. })

Install

  1. yarn add @cuillere/core

Authors

👤 Valentin Cocaud

👤 Nicolas Lepage

🤝 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 © 2020 CuillereJS.

This project is Apache-2.0 licensed.


This README was generated with ❤️ by readme-md-generator