{"id":18483716,"url":"https://github.com/ashetm/npm-myjsql","last_synced_at":"2025-09-09T18:19:59.291Z","repository":{"id":47927974,"uuid":"228825104","full_name":"AsheTM/npm-myjsql","owner":"AsheTM","description":null,"archived":false,"fork":false,"pushed_at":"2023-01-05T03:16:14.000Z","size":230,"stargazers_count":0,"open_issues_count":5,"forks_count":0,"subscribers_count":3,"default_branch":"master","last_synced_at":"2024-12-25T14:07:21.333Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","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/AsheTM.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":"2019-12-18T11:24:09.000Z","updated_at":"2020-09-04T18:11:11.000Z","dependencies_parsed_at":"2023-02-03T08:16:24.367Z","dependency_job_id":null,"html_url":"https://github.com/AsheTM/npm-myjsql","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AsheTM%2Fnpm-myjsql","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AsheTM%2Fnpm-myjsql/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AsheTM%2Fnpm-myjsql/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AsheTM%2Fnpm-myjsql/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/AsheTM","download_url":"https://codeload.github.com/AsheTM/npm-myjsql/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":239201381,"owners_count":19599074,"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":[],"created_at":"2024-11-06T12:37:01.520Z","updated_at":"2025-02-16T21:31:37.698Z","avatar_url":"https://github.com/AsheTM.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"\nMyJQL\n=============\n\nA library to simplify the usage of `mysql` module by chainning differents methods to construct a query and then execute it.\n\nWe provide the CRUD utils functions: `SELECT`, `INSERT`, `UPDATE` and `DELETE`.\n\n\n\nInstallation\n------------\n\nTo use with node:\n\n```bash\n$ npm install --save myjql\n```\n\n\n\nUsage\n-----------------\n\n```javascript\n...\nconst myjql = require('myjql');\n...\n```\n\n\n### Connecting to MySQL Database\n\n\n```javascript\n...\nmyjql.connect({    // Return object same as `createConnection` \n                    // of the module `mysql`\n                    // You can work with as you are working `mysql`\n                    // Same as `createConnection`\n        \"host\"      :   \"localhost\", \n        \"user\"      :   \"root\", \n        \"password\"  :   \"root\", \n        \"database\"  :   \"randomDB\"\n    });\n...\n```\n\n\n### SELECT Query\n\n\n```javascript\n...\nlet selectFromQuery = myjql.Query\n    .select('colA, colB')       // String of cols with `,` between each col\n // .select(['colA', 'colB'])   // Or an Array that contains different cols\n    .from('tableA')             // Table as string (Only string is supported)\n    .where()\n        .attr('age')\n            .gte(25)\n//  .where()\n//      .attr('age')\n//          .gt(25)\n//  .where()\n//      .attr('age')\n//          .lte(25)\n//  .where()\n//      .attr('age')\n//          .lt(25)\n//  .where()\n//      .attr('age')\n//          .equals(25)\n    .and()\n        .attr('name')\n            .like('%somename')\n    .and()\n        .attr(\"something\")\n            .eq()               // If nothing given, it replace it by '?'\n    .exec([\"18\"]);              // Data given in order to replace the '?' value\n                                // in the same order of the 'attr'\n...\n```\n\n\n### INSERT Query\n\n\n```javascript\n...\nlet insertIntoQuery = myjql.Query\n    .insert('tableA')                   // Table as string (Only string is supported)\n        .cols('colA, colB, colC')       // String of cols with `,` between each col\n//      .cols(['colA', 'colB', 'colC']) // Or an Array that contains different cols\n        .values([                       // Array of string\n            '\\'Value1\\', \\'Something\\', 25', \n            '\\'Value2\\', \\'Something\\', 25', \n            '\\'Value3\\', \\'Something\\', 25', \n        ])\n        .exec();\n...\n```\n\n\n### UPDATE Query\n\n\n```javascript\n...\nlet updateQuery = myjql.Query\n    .update('tableA')                           // Table as string (Only string is supported)\n        .set('onlyOneColName', 'theNewValue')   // Set the col and its value\n                                                // If a string given in 1st arg, \n                                                // then the second arg its value is '?'\n//      .set([                                  // If a lot values must be changed,\n//          { column: 'colA', value: 'NewValue' }\n//          { column: 'colB', value: 25 }\n//          { column: 'colC', value: true }\n//      ])                                      // you can give like this\n        .where()                                // You can also chain it with where\n            .attr('colId')\n                .equal(25)\n        .exec();\n...\n```\n\n\n### DELETE Query\n\n\n```javascript\n...\nlet deleteFromQuery = myjql.Query\n    .delete('tableName')                        // Table as string (Only string is supported)\n    .where()\n        .attr('idColumn')\n            .equal(20);\n    .exec();\n// Or\ndeleteFromQuery = myjql.Query\n    .delete()\n        .from('tableName')\n    .where()\n        .attr('idColumn')\n            .equal(20);\n    .exec();\n...\n```\n\n\n### From Query To String\n\n\n```javascript\n...\n// If you want to get the query string\nlet query = myjql.Query\n    .select(\"*\")\n        .from(\"tableName\");\nquery.toString();   // 'SELECT * FROM tableName'\n...\n```\n\n\n### Create an Query Object from my own query String\n\n\n```javascript\n...\n// If you have your own query string\nlet ownQuery = myjql.Query.of(\"...\");\n```\n\n\n\nSecurity issues\n-----------------------------------\n\n\n\nSecurity issues should be reported through GitHub by opening a GitHub issue \nsimply asking or by emailing the module's author/contributors.\n\nAn ideal report would include a clear indication of what the security issue is\nand how it would be exploited.\n\n\n\nContributing\n-----------------------------------\n\n\n\nThis project welcomes contributions from the community. Contributions are\naccepted using GitHub pull requests. If you're not familiar with making\nGitHub pull requests, please refer to the\n[GitHub documentation \"Creating a pull request\"](https://help.github.com/articles/creating-a-pull-request/).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fashetm%2Fnpm-myjsql","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fashetm%2Fnpm-myjsql","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fashetm%2Fnpm-myjsql/lists"}