postgREST可以找到关系

时间:2018-12-01 05:42:36

标签: postgresql postgrest

我正在尝试设置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。我看不到该架构属于哪个数据库

1 个答案:

答案 0 :(得分:0)

似乎您定位的数据库错误,请检查db-uri的配置值,并确保此uri包含api.todospsql的表。

还要澄清一下search_path是PostgREST对每个请求的修改,因此,如果您ALTER您的连接用户search_path对PostgREST搜索的架构没有影响。