Created
January 1, 2015 18:23
-
-
Save joevandyk/6584c8deffe283573bd3 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
### Create a table that has name and email, and create a view that versions the way to access the table. | |
tanga_dev=# create table foos (id serial primary key, name text, email text); | |
tanga_dev=# create view "1".foos as (select * from foos); | |
### That's all the code, now we can use http to get, read, update, and delete the data. | |
$ curl -d '{"name": "bob", "email": "[email protected]"}' http://localhost:3000/foos | |
$ curl http://localhost:3000/foos | |
[{"id":3,"name":"bob","email":"[email protected]"}] | |
$ curl -d '{"name": "joe", "email": "[email protected]"}' http://localhost:3000/foos | |
$ curl http://localhost:3000/foos | |
[{"id":3,"name":"bob","email":"[email protected]"},{"id":4,"name":"joe","email":"[email protected]"}] | |
$ curl -X PATCH -d '{"email": "[email protected]"}' http://localhost:3000/foos?id=eq.4 | |
$ curl http://localhost:3000/foos | |
[{"id":3,"name":"bob","email":"[email protected]"},{"id":4,"name":"joe","email":"[email protected]"}] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment