{"id":23024473,"url":"https://github.com/thipages/js-crud-api","last_synced_at":"2025-08-14T11:32:09.428Z","repository":{"id":57282991,"uuid":"274794061","full_name":"thipages/js-crud-api","owner":"thipages","description":"JavaScript client library for the API of PHP-CRUD-API","archived":false,"fork":false,"pushed_at":"2024-03-23T01:14:26.000Z","size":73,"stargazers_count":24,"open_issues_count":0,"forks_count":4,"subscribers_count":4,"default_branch":"master","last_synced_at":"2024-03-23T02:28:29.712Z","etag":null,"topics":["crud","database","javascript","php-crud-api","rest-api"],"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/thipages.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}},"created_at":"2020-06-25T00:05:17.000Z","updated_at":"2024-03-23T02:28:49.656Z","dependencies_parsed_at":"2024-03-23T02:28:40.046Z","dependency_job_id":"c7dcb1c5-2b34-4ea5-8d26-9d9750c1a0da","html_url":"https://github.com/thipages/js-crud-api","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/thipages%2Fjs-crud-api","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/thipages%2Fjs-crud-api/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/thipages%2Fjs-crud-api/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/thipages%2Fjs-crud-api/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/thipages","download_url":"https://codeload.github.com/thipages/js-crud-api/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":229822266,"owners_count":18129511,"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":["crud","database","javascript","php-crud-api","rest-api"],"created_at":"2024-12-15T13:18:50.032Z","updated_at":"2024-12-15T13:18:50.477Z","avatar_url":"https://github.com/thipages.png","language":"JavaScript","readme":"# JS-CRUD-API\n\nJavaScript client library for the API of [PHP-CRUD-API](https://github.com/mevdschee/php-crud-api)\n### jca-filter\n[JCA-FILTER](https://github.com/thipages/jca-filter)\n facilitates filters creation for JS-CRUD-API\n\n# Installation\n- via npm : _npm i js-crud-api_\n\n```javascript\nimport jscrudapi from 'js-crud-api';\nconst jca=jscrudapi('urlToApi.php');\njca.read('aTable',1);\n```\n- via HTML\n```html\n\u003cscript src=\"min.js\"\u003e\u003c/script\u003e\n\u003cscript\u003e\n    const jca=jscrudapi('urlToApi.php');\n    jca.list('aTable');\n\u003c/script\u003e\n```\n\n# Promise-based\nAll functions (see API) are promise-based\n```javascript\n    jca.create('atable', {field:'value'}).then(\n        result=\u003econsole.log(result)    \n    ).catch (\n        error=\u003econsole.log(error)\n    );\n```\nErrors\n- PHP-CRUD-API error codes and related messages are listed [here](https://github.com/mevdschee/php-crud-api#errors)\n- An generic javascript related error code has been added : -1 (eg fetch network error)\n\n## API\n\nJS-CRUD-API accesses PHP-CRUD-API with the following functions\n\n- **CRUD functions**\n\n| CRUD functions                 | examples                       |\n| ------------------------------ | ------------------------------ |\n| read (table,ids,conditions={}) | ```read('atable', 1)```        |\n|                                | ```read('atable', '1,2')```    |\n|                                | ```read('atable', [1,2])```    |\n|                                | ```read('atable', 1,{join:'anotherTable'})```    |\n| list (table, conditions={})    | ```list('atable')```           |\n|                                | ```list('atable', {filter:'id,eq,1'})``` |\n|                                | ```list('atable', {filter:['id,eq,1','id,eq,2']})``` |\n|                                | [other conditions here](#conditions)\n| create (table,data)            | ```create('atable', {field:'value'})```      |\n|                                | ```create('atable', [{field:'value1'},{field:'value2'}])```      |\n| update (table,idOrList,data)   | ```update('atable',1 {field:'newValue'})```      |\n|                                | ```update('atable','1,2' [{field:'newValue1'},{field:'newValue2'}])```      |\n|                                | ```update('atable',[1,2] [{field1:'newValue1'},{field2:'newValue2'}])```      |\n| delete (table,idOrList)        | ```delete('atable',1)```      |\n|                                | ```delete('atable','1,2')```  |\n|                                | ```delete('atable',[1,2])```  |\n\n- **Authentication functions** ([see documentation](https://github.com/mevdschee/php-crud-api#database-authentication))\n\n  * ```register(username,password)```\n  * ```login (username,password)```\n  * ```password (username,password,newPassowrd)```\n  * ```logout()```\n  * ```me()```\n\n\n\n\n## Conditions\nConditions are stored as object properties, values as (array of) string/number\n\n- **FILTERING** ([documentation](https://github.com/mevdschee/php-crud-api#filters))\n  ```javascript\n  jca.read('aTable', {filter:'field,modifier,value'});\n  jca.read('aTable', {filter:['field1,modifier1,value1','field2,modifier2,value2']}); // AND\n  jca.read('aTable', {filter:'field1,modifier1,value1',filter1:'field2,modifier2,value2'}); // OR\n  ```\n  \u003cins\u003eModifiers\u003c/ins\u003e\n  * cs(contain string), sw(start with), ew(end with), eq(equal), lt(lower than), le(lower or equal), ge(greater or equal), gt(greater than), bt(between), in, is(is null)\n  * filters can be negated by prepending a \"n\" character (eg \"eq\" becomes \"neq\")\n  \n- **JOINING** ([documentation](https://github.com/mevdschee/php-crud-api#joins))\n    ```javascript\n  jca.read('aTable', {join:'table1'});\n  jca.read('aTable', {join:'table1,table2'});         // path : atable\u003etable1\u003etable2\n  jca.read('aTable', {join:['table1','table2']});     // path : atable\u003etable1\u003etable2\n  jca.read('aTable', {join:[['table1'],['table2']]}); // paths: atable\u003etable1 and atable\u003etable2\n  ```\n\n- **SIZING**\n  ```javascript\n  jca.read('aTable', {size:10});\n  ```\n- **PAGINATING**\n  ```javascript\n  jca.read('aTable', {page:'1,50'});\n  jca.read('aTable', {page:1});\n  ```\n- **SELECTING COLUMN**\n    ```javascript\n  jca.read('aTable', {include:'field'});\n  jca.read('aTable', {include:['field1,field2']});\n  jca.read('aTable', {exclude:['field1']});\n  ```\n- **ORDERING**\n  ```javascript\n  jca.read('aTable', {order:'field,desc'});\n  jca.read('aTable', {order:['field1,desc','field2']});\n  ```\n\n## Limitations\n\n- Endpoints not (yet) implemented\n  * /openapi\n  * /geojson\n  * /columns\n  * /status/ping\n  \n- Only DBAuth is implemented (not basic and JWT authentications)\n\n## Tests\n\n- PHP-CRUD-API v2.14.25\n- SQLite v3.43.2\n\n\n\n\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fthipages%2Fjs-crud-api","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fthipages%2Fjs-crud-api","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fthipages%2Fjs-crud-api/lists"}