{"id":24387131,"url":"https://github.com/elzeardjs/joixsql","last_synced_at":"2026-05-07T18:16:08.001Z","repository":{"id":57281504,"uuid":"273590334","full_name":"elzeardjs/joixsql","owner":"elzeardjs","description":"JOIxSQL automatizes table creation and migration on MySQL and MariaDB on top of Knex, based on Joi Objects","archived":false,"fork":false,"pushed_at":"2022-03-03T03:26:22.000Z","size":200,"stargazers_count":0,"open_issues_count":1,"forks_count":1,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-10-21T17:59:33.429Z","etag":null,"topics":["joi","knex","mariadb","mysql"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/elzeardjs.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2020-06-19T21:32:01.000Z","updated_at":"2022-02-24T15:15:33.000Z","dependencies_parsed_at":"2022-09-12T09:00:44.171Z","dependency_job_id":null,"html_url":"https://github.com/elzeardjs/joixsql","commit_stats":null,"previous_names":["arysociety/joixsql"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/elzeardjs/joixsql","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/elzeardjs%2Fjoixsql","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/elzeardjs%2Fjoixsql/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/elzeardjs%2Fjoixsql/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/elzeardjs%2Fjoixsql/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/elzeardjs","download_url":"https://codeload.github.com/elzeardjs/joixsql/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/elzeardjs%2Fjoixsql/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":32749888,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-07T02:14:30.463Z","status":"ssl_error","status_checked_at":"2026-05-07T02:14:29.405Z","response_time":62,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.6:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"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":["joi","knex","mariadb","mysql"],"created_at":"2025-01-19T12:21:52.894Z","updated_at":"2026-05-07T18:16:07.984Z","avatar_url":"https://github.com/elzeardjs.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003cp align=\"center\" font-style=\"italic\" \u003e\n  \u003ca\u003e\n    \u003cimg alt=\"acey\" src=\"https://siasky.net/LADIrJJw-LSGC_dYiPBMwklV65NE-w9rqY-bKWHJiXmH_g\" width=\"100%\"\u003e\n  \u003c/a\u003e\n\u003c/p\u003e\n\n\u003cbr /\u003e\n\n### What if you could automatize your MySQL/MariaDB table creation and migration based on your **[Joi](https://joi.dev/api)** schemas ?\n\n*Well, now you can.*\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\n## Get Started:\n\n\u003cp align=\"right\" font-style=\"italic\"\u003e\n  \u003ca target=\"_blank\" href=\"https://github.com/elzeardjs/joixsql/tree/master/example\"\u003eRun the example\u003c/a\u003e\n\u003c/p\u003e\n\n\n```ts\nimport { Joi, TableEngine, config, Ecosystem, MigrationManager } from 'joixsql'\n\n/* Create a todo schema */\nconst Todo = Joi.object({\n    id: Joi.number().autoIncrement().primaryKey(),\n    content: Joi.string().min(1).max(400).default(''),\n    created_at: Joi.date().default(() =\u003e new Date()),\n})\n\n/* Connect the schema with a table name */\nconst todoTable = {schema: Todo, tableName: 'todos'}\n\n/* Instance a new ecosystem of Tables */\nconst ecosystem = new Ecosystem()\necosystem.add(todoTable)\n\n/* Do every available tests to check the model is receivable by MySQL/MariaDB */\necosystem.verify(todoTable).all()\n\n//We set the package configuration before running the table builder and the migration detector.\nconfig.set({\n    historyDir: './history',\n    mysqlConfig: {\n        host: 'localhost',\n        user: 'user',\n        password: 'password',\n        database: 'database'\n    },\n    ecosystem: ecosystem \n})\n\nconst main = async () =\u003e {\n\n    /* Will build all the tables present in the ecosystem that have not been created yet. */\n    await TableEngine.buildAllFromEcosystem()\n\n    /*\n    Will migrate all the tables present in the ecosystem for the already existing tables\n    that differ from their previous state recorded in the history\n    */\n    await MigrationManager.smartMigration()\n}\n\nmain()\n```\n\n\u003cbr /\u003e\n\u003cbr /\u003e\n\n\n## Extensions :\n\n### General:\n\n#### general: unique\n\nunique() set a SQL Unique constraint\n\n```ts\nJoi.object({\n    email: Joi.string().email().unique()\n})\n```\n\n#### general: group\n\ngroup() has NO effect on MySQL/MariaDB. \nFeature enabled to allow feature developement on top of JOIxSQL, for classifying columns data, to render them only when they are included in a group, to avoid rendering the whole object when no need.\n\n```ts\nJoi.object({\n    email: Joi.string().email().group(['full', 'preview'])\n})\n```\n\n#### general: Default \n\ndefault() will do a DEFAULT constraint on MySQL/Maria\n\n```ts\nJoi.object({\n    count: Joi.number().max(150).min(0).default(0)\n})\n```\n\n#### general: Foreign Key \n\nforeignKey() indicates that **'title'** is the FOREIGN KEY of the column **'id'** in the table **'categories'**\n\n```ts\nJoi.object({\n    title: Joi.string().foreignKey('categories', 'id')\n})\n```\n\n\n#### general: Cascades (only with foreign key)\n\n```ts\nJoi.object({\n    title: Joi.string().foreignKey('categories', 'id').deleteCascade().updateCascade()\n})\n```\n\n#### general: Populate\n\npopulate() indicates the link between two columns from different tables without sql consequences.\n\u003cbr /\u003e\nThis extension has been added to enable feature developement on top of JOIxSQL for formating rendered data for example.\n\n```ts\nJoi.object({\n    title: Joi.string().populate('categories', 'id')\n})\n```\n\n#### general: Required\n\nrequired() set the column as NOT NULL SQL constraint\n\n```ts\nJoi.object({\n    title: Joi.string().allow(\"Lord\", \"King\", \"Prince\").required()\n})\n```\n\n\u003cbr /\u003e\n\u003cbr /\u003e\n\n### Strings\n\n#### strings: email and other types\n\nString types like email() automatically set the column's right data type:\n- email, domain, hostname, ipVersion: **255 chars** max.\n- dataUri, uri, uriCustomScheme, uriRelativeOnly: **90,000 chars** max.\n- guid: **70 chars** max.\n- creditCard, ip, isoDate, isoDuration: **32 chars** max.\n\n```ts\nJoi.object({\n    email: Joi.string().email(),\n    credit_card: Joi.string().creditCard()\n    ...\n})\n```\n\n#### strings: min() / max()\n\nmin(), and max() will determine the sql data type. https://www.mysqltutorial.org/mysql-text/\n\n```ts\nJoi.object({\n    username: Joi.string().min(3).max(20)\n})\n```\n\n#### strings: Nothing\n\nIf no max() nor string type is set, the SQL type will be by default TEXT (max 65,535 chars)\n\n```ts\nJoi.object({\n    username: Joi.string()\n})\n```\n\n#### strings: Allow (Enum)\n\nallow() set the column as a MySQL/Maria ENUM\n\n```ts\nJoi.object({\n    title: Joi.string().allow(\"Lord\", \"King\", \"Prince\")\n})\n```\n\n\n\u003cbr /\u003e\n\u003cbr /\u003e\n\n### Numbers\n\n#### numbers: Primary key\n```ts\nJoi.object({\n    id: Joi.number().primaryKey()\n})\n```\n\n#### numbers: Auto increment\n\nIncrement each new row on MYSQL / MariaDB\n\n```ts\nJoi.object({\n    id: Joi.number().primaryKey().autoIncrement()\n})\n```\n\n#### numbers: Float\n\nFloat number type: https://dev.mysql.com/doc/refman/8.0/en/floating-point-types.html\n\n```ts\nJoi.object({\n    //max 999,999,999.99; min -999,999,999.99\n    amount: Joi.number().float(11, 2)\n    //max 99.999; min -99.999\n    amount_2: Joi.number().float(5, 3)\n})\n```\n\n#### numbers: Double\n\nDouble number type: min -1.7976931348623157E+308, max 1.7976931348623157E+308\n\n```ts\nJoi.object({\n    stars_count: Joi.number().double()\n})\n```\n\n#### numbers: Allow (Enum)\n\nallow() set the column as a MySQL/Maria ENUM\n\n```ts\nJoi.object({\n    class: Joi.number().allow(1, 2, 3)\n})\n```\n\n#### numbers: port\n\nNumbers types like portSet() automatically set the column's right data type:\n- portSet: int unsigned | min: 0, max: 4,294,967,295.\n\n```ts\nJoi.object({\n    port: Joi.number().port(),\n})\n```\n\n#### numbers: min() / max()\n\nmin(), and max() will determine the sql data type (https://github.com/elzeardjs/joixsql/blob/master/src/table-engine/mysql/types.ts)\n\n```ts\nJoi.object({\n    //Here: Unsigned int\n    player_id: Joi.number().min(0).max(2_000_000_000)\n})\n```\n\n#### numbers: positive\n\npositive() is equivalent to min(\u003e=0). It will set the number as unsigned (if integers)\n\n```ts\nJoi.object({\n    //Here: Unsigned int\n    player_id: Joi.number().positive().max(2_000_000_000)\n})\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Felzeardjs%2Fjoixsql","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Felzeardjs%2Fjoixsql","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Felzeardjs%2Fjoixsql/lists"}