Serverless MySQL: v1.5.0 released

Serverless MySQL v1.5.0 is a maintenance/security update that also adds a new feature to transaction handling allowing you to return null queries to simplify conditional transaction workflows.

Simplified Conditional Transactions

You can now return a null or empty response from .query() calls within a transaction. This lets you perform conditional transactions like this:

javascript
let results = await mysql.transaction() .query('DELETE FROM table WHERE id = ?', [someVar]) .query((r) => { if (r.affectedRows > 0) { ['UPDATE anotherTable SET x = 1 WHERE id = ?', [someVar]] } else { return null } }) .rollback(e => { /* do something with the error */ }) // optional .commit() // execute the queries

If the record to DELETE doesn't exist, the UPDATE will not be performed. If the UPDATE fails, the DELETE will be rolled back.

Feedback and contributions are always welcome on GitHub.

Updates include:

  • Add support for empty queries in transactions c733279
  • Add InnoDB note to README 6a80cc7
  • Add documentation for null transaction queries 3de167a
  • Lodash (dev dependency) version update (npm vulnerabilities) ae58d16
  • Add files directive to package.json for smaller NPM module size 60df2b4

Check out the Serverless MySQL NPM module to see how simple it is to manage MySQL at Serverless Scale.

NPM: https://www.npmjs.com/package/serverless-mysql

GitHub: https://github.com/jeremydaly/serverless-mysql

Comments are currently disabled, but they'll be back soon.