Giter VIP home page Giter VIP logo

postgrest-docs's Introduction

postgrest-docs's People

Contributors

abernicchia-heroku avatar agent3bood avatar begriffs avatar dependabot[bot] avatar develop7 avatar divslinger avatar dk1983 avatar elimisteve avatar exahilosys avatar fgribreau avatar fjf2002 avatar kiwicopple avatar kyle-johnson avatar laurenceisla avatar leondutoit avatar monacoremo avatar mrexodia avatar nileshtrivedi avatar parashoe avatar paulovieira avatar pjlindsay avatar ppkrauss avatar priyank-purohit avatar probableprime avatar rested avatar russelldavies avatar schmittr avatar steve-chavez avatar taimoorzaeem avatar wolfgangwalther avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

postgrest-docs's Issues

Migrate docs to the main code repository

Having documentation live with the code has some benefits:

  • Discoverability: I spent a while digging through begriffs/postgrest looking for the docs to submit a docs correction, before I found this repo.
  • Synchronization: Commits and pull-requests would atomically change source and documentation together.
  • History: Finding old docs, or docs specific down to a specific commit in the source, would be the same as finding that version's source-code -- no cross-referencing or guesswork.
  • Precedent: Many other projects do it this way. (I'm lazy but can get a list of examples if you want).

@begriffs summarized the original reasoning behind having this separate docs repo in begriffs/postgrest#805

  1. Might want to store big assets like pictures in there (for instance all those pictures for the Heroku docs in 0.3) and don't want to slow people or CI down during the git clone.
  2. Didn't want to litter the root of the project with docs configuration, but might not be a big deal.

In my opinion, the costs outweigh the benefit of those two points, but I guess it's somewhat subjective.

If a pull-request to move the docs to the main repo would be accepted, I'd be happy to start working on it :)

How to hook on operations aka Where goes business logic?

Assume that when a record is created in a table, an email needs to be sent out. Also, some front-end admin tool (like admin-on-rest) is operating against the api created by postgrest. Where would the logic go that sends the email after the record is created?

I assume in this case we need an additional backend on (Node.js for example) that proxies the rest interface by postgrest (effectively sits between the postgrest api and the admin tool), and will intercept some operations and do additional stuff (like sending the email).

Can you share some thoughts on this topic?

Add section about performing external actions

How to hook up a queue to listen/notify and read items from the queue. Alternately how to log events to be done in an internal table. Crib from articles online about how to get the locking semantics right in sql.

user authentication and updating users view to basic_auth.users table

I have a view that a coworker created based on the authentication example for postgrest. I was wondering now if it should use the WITH local CHECK OPTION. It currently uses a trigger. It does not work as expected. The view is:

CREATE OR REPLACE VIEW users AS
  SELECT
    actual.role       AS role,
    '***' :: TEXT     AS pass,
    actual.id         AS id,
    actual.email      AS email,
    actual.first_name AS first_name,
    actual.last_name  AS last_name,
    actual.verified   AS verified,
    actual.blocked    AS blocked
  FROM basic_auth.users AS actual,
    (SELECT rolname
     FROM pg_authid
     WHERE pg_has_role(current_user, oid, 'member')
    ) AS member_of
  WHERE actual.role = member_of.rolname
-- needed for update/insert ???
-- WITH local CHECK OPTION;

If I use the WITH local CHECK OPTION, I get an error - WITH CHECK OPTION is supported only on automatically updatable views. I assume because of the sub-select?

The trigger is:

DROP TRIGGER IF EXISTS update_users
ON users;

CREATE TRIGGER update_users
INSTEAD OF INSERT OR UPDATE OR DELETE ON
  users FOR EACH ROW EXECUTE PROCEDURE update_users();

I use my browser UI to sign up/register a new user. Then if I go to users view in the DB (through my Postico postgres GUI client), edit the view's record so that I make it "verified = true", and change the role from "verfication_pending" to "verfiied_user". The underlying table does get updated, BUT I can't signin/login with that user (invalid credentials error from postgREST). If I update the basic_auth.users table directly with the exact same edits as I do to the view (again through my postico GUI), I can sign in successfully with that user through the browser. So there is something different happening when the update occurs through the view.

Another thing I was concerned about with the trigger: Is that looping over every user in the users view? Or is it looping over a set of just the user record that is being updated? (I wish there was some optional, well-defined, built in auth mechanism for postgREST)

Prevent full table deletes or updates by using Nginx

Postgrest will allow

DELETE /foos

which without any filters will happily delete the entire table. We should document an nginx config which will prevent deletes or patches that lack filters (or at least require some other confirmation parameter in the request).

Multi language support

It would be helpful to have multi language version ๐Ÿ˜„
Is there anything I can do? I'd like to contribute with it.

Document that postgrest is sometimes unable to bind to localhost

It appears in PostgREST/postgrest#899 that centos7 may not include a localhost alias in its /etc/hosts file, so postgrest is unable to bind there. The default binding of *4 does work, but investigate if there's a suitable alternative for people who want to host locally but not expose the server to the outside world. Perhaps 127.0.0.1 works. Document this in the configuration section.

Support JSON keys containing hyphens in RPCs.

I am implementing CSP reporting using a RPC callback.

Such a report looks like:

{
  "csp-report": {
    "document-uri": "http://example.com/signup.html",
    "referrer": "",
    "blocked-uri": "http://example.com/css/style.css",
    "violated-directive": "style-src cdn.example.com",
    "original-policy": "default-src 'none'; style-src cdn.example.com; report-uri /_/csp-reports"
  }
}

Unfortunately, the standard requires using hyphens in the key name and PostgreSQL does not support using hyphens in named arguments. The standard only allows supplying an URI. Note that in this use case I do not control the request headers.

Possible solutions are:

  • Normalize named arguments by replacing - with _ (and perhaps some other chars).
  • Allow RPC calls without named arguments, instead taking one verbatim JSON argument.

The later has my preference: it is intuitively simple and can handle all JSON input. It would require some means of deciding whether to map the JSON to named arguments or not. Headers are not an option in my use case. Perhaps we can special case functions that have one named argument postgrest_raw_json json.

Promote 0.3.2 to be a first-class version in the docs

At the bottom of the table of contents at postgrest.com there is a version number selector that shows all branches/tags with version numbers that I have marked as "active." If we port the v0.3.2 branch from markdown to restructured text then I can activate it as a version that is selectable. That's how new versions will be too, so it it would be consistent that way. There are many people who are not ready to upgrade to v0.4 because of its backward incompatible changes, and these people would like easy access to the docs.

@uniphil you said you'd like to send a pull request to fix up that branch?

To review your changes locally you can

  1. Install sphinx on your development machine.
  2. sphinx-build -b html -a -n . _build then open _build/index.html in your browser.
  3. Alternately sphinx-autobuild -b html -a -n . _build will run a temporary server on localhost which refreshes the browser on every change.

You'll want to add _build to .gitignore because it gets generated fresh on the Read The Docs server.

Update inaccurate statement about application/vnd.pgrst.object

When a singular response is requested but no entries are found, the server responds with an empty body and 404 status code rather than the usual empty array and 200 status.

For empty results we actually respond with HTTP 406 because the response is incompatible with the content type requested.

Calling a rpc procedure with array parameters

HI,
I will only ask, if is it possible to make a request of a procedure with an array in parameters?

CREATE OR REPLACE FUNCTION public.test_array(input text[])
  RETURNS integer[] AS
$BODY$declare 
ret integer[];
val integer;
txt text;
begin


FOREACH txt in array  test_array.input
loop
 val = cast( txt as integer ) ;
 ret = array_append(ret,val);
end loop;
return ret;
end;$BODY$

Thanks

[Request] Add compelling example of impressive functionality(Resource Embedding)

At https://postgrest.com/en/v0.4/api.html it says:

PostgREST can also detect relations going through join tables. Thus you can request the Actors for Films (which in this case finds the information through Roles).

That is awesome, and just what I need for something I'm building right now. Please show what the query/request looks like to do this! I can imagine a case where there are multiple tables that are join tables, and I'm not sure how PostgREST distinguishes between them.

Return Full object from INSERT Trigger

The issue:
As stated several places in the docs, you can return a full object from a POST.
But this is especially difficult in regards to the "Multiple Tables Insertion or Update" guide section.

This is because a Trigger returns the "NEW" data, which is only the data passed in the actual POST.
If your trigger, for example, does an INSERT that creates a PK for a row, that data will not be in the "NEW" data.

A very easy fix for this would be to do a SELECT into the "NEW" before returning "NEW".

SELECT * INTO NEW FROM [table] WHERE [field]=[row PK];
RETURN NEW;

As someone in the Gitter channel pointed out, this might be something others have issues with, so this could be something to add into the docs.
See pastebin link for Gitter conversation.

Document connect strings for older versions of libpq

Hi

I used the centos 6 build for release 0.3.2.0 on a RHEL 6 machine and started postgrest in the same way as the documentation describes (https://github.com/begriffs/postgrest-docs/blob/master/docs/install/server.md#running-the-server).

Doing this, however, does not work. The service starts but as soon as one does a request it fails to connect to the db and returns a rather cryptic error message: {"details":"missing \"=\" after \"postgres://db_owner@db-host:5432/db_name\" in connection info string\n","code":"","message":"Connection error"}.

After some discussion with @ruslantalpa on gitter he suggested that I use a different form of connection string. Turns out that passing the connection string like this "host=hostname user=username port=5432 dbname=dbname" to postgrest works fine.

I would like to do a pull request to make other users aware of this detail for centos 6 builds but I am not sure where this should fit into the documentation. One possibility would be to add a small subsection or a note in https://github.com/begriffs/postgrest-docs/blob/master/docs/install/server.md#running-the-server.

If you would like me to add this to the docs please let me know where.

cheers
Leon

binary is xz not gzip

On rhel7 I had to use this:
tar Jxf postgrest-0.4.1.0-centos.tar.xz
Instead of this (from install doc):
tar zxf postgrest-[version]-[platform].tar.xz

I'm not a unix wizard so I could be missing something

Document how to use Heroku + RDS

  • Using the deploy to heroku button on the repo
  • Describe available options
  • Show the anatomy of a postgresql connection string
  • Mention RDS IP permissions
  • Keeping the DB geographically near the heroku dyno (virginia region)

Fix broken front-page video

Its vimeo privacy settings prevent it from playing.

Is this even the video we want to present? It's pretty old. Do we want a video on the front page?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.