Questions tagged [postgrest]

PostgREST serves a fully RESTful API from any existing PostgreSQL database. It provides a cleaner, more standards-compliant, faster API. It differs from the other emerging API servers by taking an opinionated stance on the full implementation of API by being operationally sound and simple to deploy, by delivering built-in security with JSON Web Tokens plus database roles, and by fully embracing the relational model.

Introduction

PostgREST is a standalone web server that turns your PostgreSQL database directly into a RESTful API. The structural constraints and permissions in the database determine the API endpoints and operations.

Motivation

Using PostgREST is an alternative to manual CRUD programming. Custom API servers suffer problems. Writing business logic often duplicates, ignores or hobbles database structure. Object-relational mapping is a leaky abstraction leading to slow imperative code. The PostgREST philosophy establishes a single declarative source of truth: the data itself.

Declarative Programming

It's easier to ask Postgres to join data for you and let its query planner figure out the details than to loop through rows yourself. It's easier to assign permissions to db objects than to add guards in controllers. (This is especially true for cascading permissions in data dependencies.) It's easier to set constraints than to litter code with sanity checks.

Leakproof Abstraction

There is no ORM involved. Creating new views happens in SQL with known performance implications. A database administrator can now create an API from scratch with no custom programming.

Embracing the Relational Model

In 1970 E. F. Codd criticized the then-dominant hierarchical model of databases in his article A Relational Model of Data for Large Shared Data Banks. Reading the article reveals a striking similarity between hierarchical databases and nested http routes. With PostgREST we attempt to use flexible filtering and embedding rather than nested routes.

One Thing Well

PostgREST has a focused scope. It works well with other tools like Nginx. This forces you to cleanly separate the data-centric CRUD operations from other concerns. Use a collection of sharp tools rather than building a big ball of mud.

136 questions
0
votes
1 answer

postgREST can find relation

I'm trying to set up postgREST. Have been following the tutorial at http://postgrest.org/en/v5.1/tutorials/tut0.html. Here is what I see. First, the schemas: entercarlson=# \dn List of schemas Name | Owner --------+--------- api |…
jxxcarlson
  • 223
  • 3
  • 13
0
votes
1 answer

How can I access PostgREST from an external PC?

How can I configure PostgREST to process requests from an external PC? If I make a request from the computer on which it is running. All work. With a remote database running. But when I run it on RDP on the server and try to contact. Nothing…
Vladimir Golub
  • 523
  • 1
  • 8
  • 22
0
votes
1 answer

PostgREST function response schema is randomly inconsistent?

When calling a REST function that returns JSON and requesting the object return schema, sometimes (randomly it seems) the result is wrapped in an object that has the function name as the only key. This makes parsing the result a bit tiresome,…
user9645
  • 6,286
  • 6
  • 29
  • 43
0
votes
1 answer

PSQL : How to get the record count of each value in a column group by another column

PSQL: My main table has 20 million records and when I run my select it runs for hours. Is there a way to better write this statment ? My table : Select * from lookup limit 10; ------------------------- month id 2010-01 598362 2010-01 …
0
votes
0 answers

Configuration the postrest with the postgresql database on Heroku or AWS

I need help related to the configuration of PostgREST with the PostgreSQL database dumped into Heroku or AWS. What are the exact steps from the beginning?
syeenn
  • 191
  • 2
  • 3
  • 11
0
votes
1 answer

How do I edit this json?

I have this code in my VIEW: SELECT json_object_agg(code,value) FROM table1 It generates this in my postgREST api: [{"json_object_agg":"{code1: value1, code2: value2, ...}"] I want to remove the json_object_agg to make it like this: [{code1:…
Joshua Rajandiran
  • 2,788
  • 7
  • 26
  • 53
0
votes
1 answer

How to start PostgREST as a ubuntu service in a cloud server?

According to PostgREST doc, we can start postgrest with postgrest postgres://user:pass@host:port/db -a anon_user [other flags] It is fine to run locally; however, how to register it as a system service and run in the cloud server?
Nick
  • 8,451
  • 13
  • 57
  • 106
0
votes
1 answer

Technique to get an id back with an http query when empty array is returned

Let me first say I have a solution to this problem, but I'm interested in knowing whether there is a better way, and whether I'm doing something wrong. I have a table of objects on the front-end of a webapp, I need to asynchronously load some data…
jgon
  • 698
  • 4
  • 11
0
votes
1 answer

PostgREST filter returns incorrect results when value contains a space

Using current version of PostgREST (v.0.3.2.0), attempting a very simple GET call: Db contains two records with the following accountNames: "Account 1" and "Account #2". This works: GET localhost:3000/accounts?accountName=eq.Account 1 ==> proper…
CCPony
  • 988
  • 1
  • 7
  • 20
0
votes
0 answers

How do I allow https on localhost?

I want to test an app API but I need to have a domain with a secure HTTP protocol for to redirect to. Currently, I don't have a domain but I've thought about the possibility of HTTPS on localhost, is that possible? PS: OS is Windows & I'm using…
Joshua Rajandiran
  • 2,788
  • 7
  • 26
  • 53
0
votes
0 answers

postgrest deployment on ubuntu

Hi I have an aws EC2 instance with ubuntu 14.04 installed. I also have a remote postgres database to which I already have made a ssh tunnel in the port 5433 of my instance and is working. So I want to make the api for the database with postgrest The…
0
votes
0 answers

issue when integrating postgrest with wso2 api manager

I am trying to integrate postgrest api into WSO2 API Manager. GET, PUT, DELETE works fine, but POST is not work correctly inside API manager. step 1: For example, I have a table named server and postgrest api for that table…
Arun M R Nair
  • 653
  • 7
  • 30
0
votes
0 answers

Setting Javascript RequestHeader With Synchronize XMLHTTPRequest

Let me explain the problem to you a little, I'm using a 3rd party plugin that runs a rest interface for executing database commands over a postgrest database. In order to limit the returned results so I don't call all 1,000 rows is to set the…
Grant Zukel
  • 1,153
  • 2
  • 24
  • 48
-1
votes
1 answer

Postgrest query. Select * from table when id = id or (user id = id and boolean = true)

Im trying to do what a simple query in postgres on postgrest. Basically this is the query I am trying to recreate (ID, Other_id and boolean are all columns in the table) SELECT * FROM TABLE WHERE ID = 'ID' OR (OTHER_ID = 'OTHER_ID' AND BOOLEAN…
c-mac
  • 83
  • 1
  • 9
-1
votes
1 answer

Can't get HTTP PATCH to work on Google Cloud Run instance

I have running a webserver called Postgrest which generates a REST API on top of a postgres DB. I have this running in Google Cloud run, and have it working for the most part. The HTTP actions I need to take are POST, GET, DELETE and…
mike hennessy
  • 1,359
  • 1
  • 16
  • 35
1 2 3
9
10