{"id":17961127,"url":"https://github.com/matissjanis/knex-serverless-mysql","last_synced_at":"2025-03-25T03:31:32.926Z","repository":{"id":83689303,"uuid":"361273845","full_name":"MatissJanis/knex-serverless-mysql","owner":"MatissJanis","description":"Knex.js dialect for serverless-mysql","archived":false,"fork":false,"pushed_at":"2021-04-26T18:47:20.000Z","size":7,"stargazers_count":12,"open_issues_count":1,"forks_count":3,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-03-14T21:05:19.497Z","etag":null,"topics":["data-source","knex","mysql","serverless","serverless-mysql"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/MatissJanis.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2021-04-24T21:49:26.000Z","updated_at":"2024-06-20T23:20:02.000Z","dependencies_parsed_at":null,"dependency_job_id":"6e684518-16bf-4cce-9a56-d9f6bacba299","html_url":"https://github.com/MatissJanis/knex-serverless-mysql","commit_stats":{"total_commits":4,"total_committers":1,"mean_commits":4.0,"dds":0.0,"last_synced_commit":"22b88e0b6cb9e8260e9265cb58debaeb2443a67c"},"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MatissJanis%2Fknex-serverless-mysql","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MatissJanis%2Fknex-serverless-mysql/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MatissJanis%2Fknex-serverless-mysql/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MatissJanis%2Fknex-serverless-mysql/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/MatissJanis","download_url":"https://codeload.github.com/MatissJanis/knex-serverless-mysql/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245394751,"owners_count":20608122,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["data-source","knex","mysql","serverless","serverless-mysql"],"created_at":"2024-10-29T11:08:22.219Z","updated_at":"2025-03-25T03:31:32.915Z","avatar_url":"https://github.com/MatissJanis.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# knex-serverless-mysql\n\n[![npm](https://img.shields.io/npm/v/knex-serverless-mysql.svg)](https://www.npmjs.com/package/knex-serverless-mysql)\n[![npm](https://img.shields.io/npm/l/knex-serverless-mysql.svg)](https://www.npmjs.com/package/knex-serverless-mysql)\n\nMinimalistic knex.js dialect for [serverless-mysql].\n\n## Motivation\n\n[serverless-mysql] persists database connections across multiple\nAWS Lambda function execution contexts. This reduces the load on\nthe database. However, this client is not natively supported by\nKnex. This library solves the problem.\n\n## Getting Started\n\n### Installation\n\n```\nyarn add knex-serverless-mysql\n\n# or\n\nnpm install knex-serverless-mysql\n```\n\n### Simple Example\n\n```js\nconst Knex = require('knex');\nconst knexServerlessMysql = require('knex-serverless-mysql');\n\nconst mysql = require('serverless-mysql')({\n  config: {\n    host     : process.env.DB_HOST,\n    database : process.env.DB_DATABASE,\n    user     : process.env.DB_USERNAME,\n    password : process.env.DB_PASSWORD,\n  },\n});\n\nconst knex = Knex({\n  client: knexServerlessMysql,\n  mysql,\n});\n\nexports.run = function () {\n  return knex('table_name').where('id', 1);\n}\n```\n\n### Usage with [datasource-sql]\n\n```js\nconst Knex = require('knex');\nconst knexServerlessMysql = require('knex-serverless-mysql');\nconst { SQLDataSource } = require('datasource-sql');\n\nconst mysql = require('serverless-mysql')({\n  config: {\n    host     : process.env.DB_HOST,\n    database : process.env.DB_DATABASE,\n    user     : process.env.DB_USERNAME,\n    password : process.env.DB_PASSWORD,\n  },\n});\n\nconst knex = Knex({\n  client: knexServerlessMysql,\n  mysql,\n});\n\nclass TableNameDataSource extends SQLDataSource {\n  getRowById(id) {\n    return this.knex('table_name').where('id', id);\n  }\n}\n\nconst dataSource = new TableNameDataSource(knex);\n\nexports.run = function () {\n  return dataSource.getRowById(1);\n}\n```\n\n## Contributing\n\nAll contributions are welcome!\n\nPlease open an issue or pull request.\n\n\n[serverless-mysql]: https://github.com/jeremydaly/serverless-mysql\n[datasource-sql]: https://github.com/cvburgess/SQLDataSource\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmatissjanis%2Fknex-serverless-mysql","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmatissjanis%2Fknex-serverless-mysql","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmatissjanis%2Fknex-serverless-mysql/lists"}