github向我推薦這個xmysql時候,我瞟了一眼它的簡介One command to generate REST APIs for any MySql Database
, 說實話這個介紹讓我眼前一亮,想一想每次向後端的同窗要個接口的時候,他們老是要哼哧哼哧
搞個半天給才能我。抱着試試看的心態,我試用了一個療程,oh不是, 是安裝並使用了一下。 說實話,體驗是蠻不錯的,可是體驗一把事後,我想不到這個工具的使用場景,由於你不可能把數據庫的全部表都公開出來,讓前端隨意讀寫,
可是試試看老是不錯的.前端
安裝與使用
mysql
npm install -g xmysql xmysql -h localhost -u mysqlUsername -p mysqlPassword -d databaseName 瀏覽器打開:http://localhost:3000, 應該能夠看到一堆json
批量插入,批量刪除,批量讀取 ?git
HTTP Type | API URL | Comments |
---|---|---|
GET | / | Gets all REST APIs |
GET | /api/tableName | Lists rows of table |
POST | /api/tableName | Create a new row |
PUT | /api/tableName | Replaces existing row with new row |
POST | /api/tableName/bulk | Create multiple rows - send object array in request body |
GET | /api/tableName/bulk | Lists multiple rows - /api/tableName/bulk?_ids=1,2,3 |
DELETE | /api/tableName/bulk | Deletes multiple rows - /api/tableName/bulk?_ids=1,2,3 |
GET | /api/tableName/:id | Retrieves a row by primary key |
PATCH | /api/tableName/:id | Updates row element by primary key |
DELETE | /api/tableName/:id | Delete a row by primary key |
GET | /api/tableName/findOne | Works as list but gets single record matching criteria |
GET | /api/tableName/count | Count number of rows in a table |
GET | /api/tableName/distinct | Distinct row(s) in table - /api/tableName/distinct?_fields=col1 |
GET | /api/tableName/:id/exists | True or false whether a row exists or not |
GET | /api/parentTable/:id/childTable | Get list of child table rows with parent table foreign key |
GET | /api/tableName/aggregate | Aggregate results of numeric column(s) |
GET | /api/tableName/groupby | Group by results of column(s) |
GET | /api/tableName/ugroupby | Multiple group by results using one call |
GET | /api/tableName/chart | Numeric column distribution based on (min,max,step) or(step array) or (automagic) |
GET | /api/tableName/autochart | Same as Chart but identifies which are numeric column automatically - gift for lazy while prototyping |
GET | /api/xjoin | handles join |
GET | /dynamic | execute dynamic mysql statements with params |
GET | /upload | upload single file |
GET | /uploads | upload multiple files |
GET | /download | download a file |
GET | /api/tableName/describe | describe each table for its columns |
GET | /api/tables | get all tables in database |
";s:4:"tags";a:5:{i:0;s:16:"1040000000090688";i:1;s:16:"1040000006048152";i:2;s:16:"1040000000607648";i:3;s:16:"1040000000089436";i:4;s:16:"1040000000089439";}}github