我正在尝试设置postgREST。一直在遵循http://postgrest.org/en/v5.1/tutorials/tut0.html上的教程。这是我所看到的。首先,架构:
entercarlson=# \dn
List of schemas
Name | Owner
--------+---------
api | carlson
public | carlson
然后创建一个表:
carlson=# \d api.todos
Table "api.todos"
Column | Type | Collation | Nullable | Default
--------+--------------------------+-----------+----------+---------------------------------------
id | integer | | not null | nextval('api.todos_id_seq'::regclass)
done | boolean | | not null | false
task | text | | not null |
due | timestamp with time zone | | |
Indexes:
"todos_pkey" PRIMARY KEY, btree (id)
最后,一些数据:
carlson=# select * from api.todos;
id | done | task | due
----+------+-------------------+-----
1 | f | finish tutorial 0 |
2 | f | pat self on back |
(2 rows)
但是我得到了:
$ curl http://localhost:3000/todos
{"hint":null,"details":null,"code":"42P01","message":"relation
\"api.todos\" does not exist"}
与此相符:
carlson=# \d
Did not find any relations.
我在做什么错了?
PS。我看不到该架构属于哪个数据库
答案 0 :(得分:0)
似乎您定位的数据库错误,请检查db-uri
的配置值,并确保此uri包含api.todos
到psql
的表。
还要澄清一下search_path
是PostgREST对每个请求的修改,因此,如果您ALTER
您的连接用户search_path
对PostgREST搜索的架构没有影响。