Show HN: Xmysql – One command to serve REST APIs for any MySql database
github.com
github.com
(At least it's not mentioned in the docs)
Though postgrest does support openapi (previously swagger), so you can use the swagger generator to emit a java client library. https://editor.swagger.io/
xmysql now supports
+ group by
+ group by, order by
+ aggregate
+ single file upload, multiple file upload and download file
+ where clause on list of resource
+ where clause on list of nested resource
https://github.com/o1lab/xmysql> ## When NOT to use ?
> - If you are in need of a full blown MVC framework, ACL, Authorisation etc - Not this.
I personally don't know if I want to build permissions in my one page micro curd api. If you are going for basics I believe access is bettered controlled by the web server(ldap/basic auth).
I'm imagining auth and permissions and such will still primarily be handled by the db in either case
You could imagine a "(web)serverless" web app with Javascript querying the DB directly over REST. Or embedded devices saving telemetry directly in a DB.
So the one page takes any arbitrary query, and forwards the query on the client's behalf, and returns the dataset to the client.
Im not sure how the provided api is better than what ive suggested; they seem to me equivalent, but xmysql a lot more annoying to write, and xmysql is doing a lot more work for what looks like no benefit
That's pretty subjective. Personally, I'd much rather write "api/foo/:id/bar?_sort=field1" than "select * from foo inner join bar on foo.id = bar.foo_id order by field1".
Not to mention that this enables people who are not as familiar with writing raw SQL to move a lot faster, which is the point when you're prototyping/hacking.
SELECT crypt( encode(digest(gen_random_bytes(1024), 'sha512'), 'base64'), gen_salt('bf', 20) ) FROM generate_series(1, 1000000)
My understanding of why Kibana could be built and become such a powerful visualization tool is because of the easy-to-use and powerful REST APIs that Elasticsearch shipped with out of the box.
Hopefully a REST API like this for MySQL will make it easy to build similar powerful tools around MySQL! It's definitely something that would have helped with the PHP / MySQL applications I built years ago.
I hadn't heard of SuperSet[1] until this post. Seems pretty interesting. Looks like there's potential for ElasticSearch support[2] as well.
1: https://github.com/apache/incubator-superset
2: https://github.com/apache/incubator-superset/issues/600#issu...
Kibana and superset look awesome. I'll have a look at them.
/api/payments?_fields=customerNumber,checkNumber
why not:
/api/payments?fields[]=customerNumber&fields[]=checkNumber
Kudos for "sort=-{field}" though (I think); any commentary on that design choice? I've used e.g. "sortdir=desc" in the past; not sure which is superior.
parameters with underscore: I'd imagined to 've 'where' parameters in query fields like ?columnName=columnValue. Hence started with underscore - however I dropped where clause as I was soon sure that I was only covering small group within where clause and operators.
abbreviation of page to _p - I think I picked up that from hackernews where paging query parameter is p :).
fields: second one seems easy to use - I think I borrowed it from google youtube apis. They have concept of id,snippet etc which is higher level of abstracting ids, primary-info (respectively) in response
sort: may be I extended the concept of fields to sort. Since sort can 've only two directions.
``` /api/payments?fields=customerNumber&fields=checkNumber ```
You don't need [] to look for multiples.
I guess I got my answer :)
It's probably the most common convention I've seen (at least for those sites that still support pagination, as opposed to that horrible "infinite scroll"...)
The underscores are a little unusual, however; I don't think it's a bad thing, unless you're deliberately trying to hide the fact that you're using a specific backend. I've seen other prefices for parameters too with other sites in the past.
Why is a non-standard syntax used for multiple values rather than just parameter arrays?
There is no standard. I believe [] came from PHP, but I've seen many different ways to express "multiple values" in query strings.
xmysql now supports
+ group by
+ group by, order by
+ aggregate
+ single file upload, multiple file upload and download file > xmysql now supports
+ where clause on list of resource
+ where clause on list of nested resource User {
name: "Bob"
id: 1
}
You would have something like this: User {
name: "Bob"
href: "http://www.example.com/api/users/1"
}Formatted summary - http://www.ics.uci.edu/%7Efielding/pubs/dissertation/rest_ar... - "The most frequent form of request semantics is that of retrieving a representation of a resource (e.g., the "GET" method in HTTP), which can often be cached for later reuse."
A critique of HTTP REST - http://cafe.elharo.com/web/why-rest-failed/ - "Representational State Transfer (REST) is the explicit architecture of HTTP and the World Wide Web" which is a notably incorrect statement.
Other interesting articles:
http://www.artima.com/lejava/articles/why_put_and_delete.htm...