PostgREST / postgrest

REST API for any Postgres database
https://postgrest.org
MIT License
23.22k stars 1.02k forks source link

Compound references how should they be entered as query? #992

Closed skinkie closed 6 years ago

skinkie commented 6 years ago

987 was helping me a lot documentation wise. But I still have a question regarding the example below.

create table Line (id text not null, version text not null,
primary key(id, version), 
Name text, 
TransportMode text, 
PublicCode text, 
Monitored boolean, 
VetagLineNumber text, 
LinePlanningNumber text);

create table Route (id text not null, version text not null,
primary key (id, version),
linerefid text, linerefversion text,
foreign key(linerefid, linerefversion) references Line(id, version));

What should be used to get both linerefid and linerefversion?

http://localhost:3000/line?select=route.linerefid(*)
ruslantalpa commented 6 years ago

http://localhost:3000/Line?select=id,version,name,Route(id, version)

PS: never use *, always write the fields explicitly and also a good idea is for each entity to include it's primary key(s)