0

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

4

1 回答 1

1

似乎您的目标数据库错误,请检查db-uri配置值并确保此 uri 包含api.todos通过psql.

另外,要澄清search_pathPostgREST 对每个请求都进行了修改,因此,如果您是ALTER您的连接用户search_path,它将对 PostgREST 搜索的模式没有影响。

于 2018-12-08T17:30:06.690 回答