xmysql: 一行命令从任何mysql数据库生成REST API

github向我推荐这个xmysql时候,我瞟了一眼它的简介One command to generate REST APIs for any MySql Database, 说实话这个介绍让我眼前一亮,想想每次向后端的同学要个接口的时候,他们总是要哼哧哼哧搞个半天给才能我。抱着试试看的心态,我试用了一个疗程,oh不是, 是安装并使用了一下。 说实话,体验是蛮不错的,但是体验一把过后,我想不到这个工具的使用场景,因为你不可能把数据库的所有表都公开出来,让前端随意读写, 但是试试看总是不错的.

1 来吧,冒险一次!

clipboard.png

安装与使用

npm install -g xmysql

xmysql -h localhost -u mysqlUsername -p mysqlPassword -d databaseName

浏览器打开:http://localhost:3000, 应该可以看到一堆json

2 特点

  • 产生REST Api从任何mysql 数据库 ??
  • 无论主键,外键,表等的命名规则如何,都提供API ??
  • 支持复合主键 ??
  • REST API通常使用:CRUD,List,FindOne,Count,Exists,Distinct

批量插入,批量删除,批量读取 ?

  • 关联表
  • 翻页
  • 排序
  • 按字段过滤 ?
  • 行过滤 ?
  • 综合功能
  • Group By, Having (as query params) ??
  • Group By, Having (as a separate API) ??
  • Multiple group by in one API ????
  • Chart API for numeric column ??????
  • Auto Chart API - (a gift for lazy while prototyping) ??????
  • XJOIN - (Supports any number of JOINS) ?????????
  • Supports views
  • Prototyping (features available when using local MySql server only)
  • Run dynamic queries ???
  • Upload single file
  • Upload multiple files
  • Download file

3 API 概览

HTTP TypeAPI URLComments
GET/Gets all REST APIs
GET/api/tableNameLists rows of table
POST/api/tableNameCreate a new row
PUT/api/tableNameReplaces existing row with new row
POST /api/tableName/bulkCreate multiple rows - send object array in request body
GET /api/tableName/bulkLists multiple rows - /api/tableName/bulk?_ids=1,2,3
DELETE /api/tableName/bulkDeletes multiple rows - /api/tableName/bulk?_ids=1,2,3
GET/api/tableName/:idRetrieves a row by primary key
PATCH/api/tableName/:idUpdates row element by primary key
DELETE/api/tableName/:idDelete a row by primary key
GET/api/tableName/findOneWorks as list but gets single record matching criteria
GET/api/tableName/countCount number of rows in a table
GET/api/tableName/distinctDistinct row(s) in table - /api/tableName/distinct?_fields=col1
GET/api/tableName/:id/existsTrue or false whether a row exists or not
GET/api/parentTable/:id/childTableGet list of child table rows with parent table foreign key
GET /api/tableName/aggregateAggregate results of numeric column(s)
GET /api/tableName/groupbyGroup by results of column(s)
GET /api/tableName/ugroupbyMultiple group by results using one call
GET /api/tableName/chartNumeric column distribution based on (min,max,step) or(step array) or (automagic)
GET /api/tableName/autochartSame as Chart but identifies which are numeric column automatically - gift for lazy while prototyping
GET /api/xjoinhandles join
GET /dynamicexecute dynamic mysql statements with params
GET /uploadupload single file
GET /uploadsupload multiple files
GET /downloaddownload a file
GET/api/tableName/describedescribe each table for its columns
GET/api/tablesget all tables in database

3 更多资料

";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";}}

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值