{"id":17918960,"url":"https://github.com/wellwelwel/mysql2-orm","last_synced_at":"2025-09-27T13:31:12.997Z","repository":{"id":64771090,"uuid":"578083345","full_name":"wellwelwel/mysql2-orm","owner":"wellwelwel","description":"🎲 An ORM built on MySQL2, designed to be intuitive, productive and focused on essential functionality.","archived":false,"fork":false,"pushed_at":"2024-12-06T04:20:28.000Z","size":2741,"stargazers_count":4,"open_issues_count":0,"forks_count":0,"subscribers_count":3,"default_branch":"main","last_synced_at":"2025-01-14T00:18:42.645Z","etag":null,"topics":["extend","extender","extends","mysql","mysql2","nodejs","orm"],"latest_commit_sha":null,"homepage":"https://wellwelwel.github.io/mysql2-orm/","language":"TypeScript","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/wellwelwel.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":".github/FUNDING.yml","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},"funding":{"github":["wellwelwel"]}},"created_at":"2022-12-14T08:08:19.000Z","updated_at":"2024-12-06T04:19:33.000Z","dependencies_parsed_at":"2024-12-06T05:20:23.547Z","dependency_job_id":"9bf5b704-c383-4f75-8398-3dd3bfaa29ea","html_url":"https://github.com/wellwelwel/mysql2-orm","commit_stats":{"total_commits":61,"total_committers":1,"mean_commits":61.0,"dds":0.0,"last_synced_commit":"bcb08e318f87fc8fc86076ad1e9a6791586d2de6"},"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wellwelwel%2Fmysql2-orm","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wellwelwel%2Fmysql2-orm/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wellwelwel%2Fmysql2-orm/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wellwelwel%2Fmysql2-orm/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/wellwelwel","download_url":"https://codeload.github.com/wellwelwel/mysql2-orm/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":234440219,"owners_count":18832970,"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":["extend","extender","extends","mysql","mysql2","nodejs","orm"],"created_at":"2024-10-28T20:13:44.862Z","updated_at":"2025-09-27T13:31:07.636Z","avatar_url":"https://github.com/wellwelwel.png","language":"TypeScript","funding_links":["https://github.com/sponsors/wellwelwel"],"categories":[],"sub_categories":[],"readme":"[mysql2]: https://github.com/sidorares/node-mysql2\n[npm-image]: https://img.shields.io/npm/v/mysql2-orm.svg\n[npm-url]: https://npmjs.org/package/mysql2-orm\n[downloads-image]: https://img.shields.io/npm/dt/mysql2-orm.svg\n[downloads-url]: https://npmjs.org/package/mysql2-orm\n[ci-url]: https://github.com/wellwelwel/mysql2-orm/actions/workflows/ci.yml?query=branch%3Amain\n[ci-image]: https://img.shields.io/github/actions/workflow/status/wellwelwel/mysql2-orm/ci.yml?event=push\u0026style=flat\u0026label=ci\u0026branch=main\n[license-url]: https://github.com/wellwelwel/mysql2-orm/blob/main/License\n[license-image]: https://img.shields.io/npm/l/mysql2-orm.svg?maxAge=2592000\n\n# MySQL2 ORM\n\n\u003cimg align=\"right\" width=\"64\" height=\"64\" alt=\"Logo\" src=\"website/static/img/favicon.svg\"\u003e\n\nAn **ORM** built on [**MySQL2**][mysql2], designed to be intuitive, productive and focused on essential functionality.\n\n[![NPM Version][npm-image]][npm-url]\n[![NPM Downloads][downloads-image]][downloads-url]\n[![GitHub Workflow Status (with event)][ci-image]][ci-url]\n[![License][license-image]][license-url]\n\n- This project uses **mysql2/promise**, **createPool** and **execute** behind the scenes.\n\n---\n\n🎲 [**Documentation Website**](https://wellwelwel.github.io/mysql2-orm/docs/)\n\n---\n\n## Table of Contents\n\n- [Why](#why)\n- [Documentation](#documentation)\n- [Quickstart](#quickstart)\n  - [Installation](#installation)\n  - [Import](#import)\n  - [Connect](#connect)\n  - [Basic Usage Example](#basic-usage-example)\n  - [Close the Connection](#close-the-connection)\n- [Curiosity](#curiosity)\n  - [Why a dice?](#why-a-dice)\n- [Acknowledgements](#acknowledgements)\n\n---\n\n## Why\n\n- An user-friendly ORM for **INSERT**, **SELECT**, **UPDATE**, **DELETE** and **WHERE** clauses.\n- Automatic **Prepared Statements** (including **LIMIT** and **OFFSET**).\n- You can also simply use **QueryBuilder** to mount your queries and use them in your original [**MySQL2**][mysql2] connection.\n- It will smartly detect and release the connection when using `commit` or `rollback` in a transaction.\n- It exposes the `execute` and `query` original methods from [**MySQL2**][mysql2] Pool class.\n- **Strictly Typed:** No usage of `any`, `as` neither `satisfies` at all.\n\n---\n\n## Documentation\n\nSee detailed specifications and usage in [**Documentation**](https://wellwelwel.github.io/mysql2-orm/docs/category/documentation) section for queries, advanced concepts and much more.\n\n---\n\n## Quickstart\n\n### Installation\n\n```shell\nnpm i mysql2-orm\n```\n\nIf you are using TypeScript, you will need to install [@types/node](https://www.npmjs.com/package/@types/node).\n\n```shell\nnpm i -D @types/node\n```\n\n---\n\n### Import\n\n```ts\nimport { MySQL } from 'mysql2-orm';\n```\n\n---\n\n### Connect\n\n```ts\nconst pool = new MySQL({\n  host: '',\n  user: '',\n  database: '',\n  // ...\n});\n```\n\n---\n\n### Basic Usage Example\n\nThe following example is based on **TypeScript** and **ES Modules**, but you can also use **JavaScript** and **CommonJS**.\n\n```ts\nconst user = await pool.select({\n  table: 'users',\n  where: OP.eq('id', 16),\n  limit: 1,\n});\n```\n\n- See all available operators (**OP**) [here](https://wellwelwel.github.io/mysql2-orm/docs/category/operators).\n- Due to `limit: 1`, it returns a direct object with the **row** result.\n- The result of **getUser** will be a `RowDataPacket` or `false`.\n\n\u003e It's equivalent to:\n\u003e\n\u003e ```ts\n\u003e import mysql, { RowDataPacket } from 'mysql2/promise';\n\u003e\n\u003e const pool = mysql.createPool({\n\u003e   // ...\n\u003e });\n\u003e\n\u003e const [users] = execute\u003cRowDataPacket[]\u003e(\n\u003e   'SELECT * FROM `users` WHERE `id` = ? LIMIT ?',\n\u003e   [16, '1']\n\u003e );\n\u003e\n\u003e const user = users?.[0] || false;\n\u003e ```\n\n---\n\n### Close the Connection\n\n```ts\nawait pool.end();\n```\n\n---\n\n## Curiosity\n\n### Why a dice?\n\nWhile in English \u003cins\u003edice\u003c/ins\u003e and \u003cins\u003edata\u003c/ins\u003e each have their own word, in Brazil, both the dice and \"data\" are called \"**dado**\" even though they refer to different things:\n\n|     | 🇺🇸 English | 🇧🇷 Portuguese (BR) |\n| --- | ---------- | ------------------ |\n| 💾  | data       | dado               |\n| 🎲  | dice       | **dado**           |\n\n---\n\n## Acknowledgements\n\n- [**MySQL2**][mysql2] is maintained by [**@sidorares**](https://github.com/sidorares).\n- The operator names **eq**, **ne**, **gt**, **lt**, **gte** and **lte** are inspired by [**Sequelize**](https://sequelize.org/docs/v6/core-concepts/model-querying-basics/#operators).\n- [**Contributors**](https://github.com/wellwelwel/mysql2-orm/graphs/contributors).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwellwelwel%2Fmysql2-orm","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fwellwelwel%2Fmysql2-orm","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwellwelwel%2Fmysql2-orm/lists"}