Skip to content

Supabase 节点常见问题#

¥Supabase node common issues

以下是 Supabase 节点 的一些常见错误和问题,以及解决或故障排除步骤。

¥Here are some common errors and issues with the Supabase node and steps to resolve or troubleshoot them.

按元数据筛选行#

¥Filtering rows by metadata

要按 Supabase 元数据 筛选行,请将“选择类型”设置为“字符串”。

¥To filter rows by Supabase metadata, set the Select Type to String.

之后,你可以在“过滤器(字符串)”参数中构建一个查询,以使用 Supabase 元数据查询语言 格式(参考 MongoDB 选择器 格式)过滤元数据。使用 Postgres ->> 箭头 JSON 运算符 访问元数据属性,方法如下(大括号表示需要填写的组件):

¥From there, you can construct a query in the Filters (String) parameter to filter the metadata using the Supabase metadata query language, inspired by the MongoDB selectors format. Access the metadata properties using the Postgres ->> arrow JSON operator like this (curly brackets denote components to fill in):

1
metadata->>{your-property}={comparison-operator}.{comparison-value}

例如,要访问元数据中的 age 属性并返回大于或等于 21 的结果,你可以在“筛选器(字符串)”字段中输入以下内容:

¥For example to access an age property in the metadata and return results greater than or equal to 21, you could enter the following in the Filters (String) field:

1
metadata->>age=gte.21

你可以组合这些运算符来构建更复杂的查询。

¥You can combine these operators to construct more complex queries.

使用 Docker 时无法连接到本地 Supabase 数据库#

¥Can't connect to a local Supabase database when using Docker

在 Docker 中运行 Supabase 时,你需要配置网络,以便 n8n 可以连接到 Supabase。

¥When you run Supabase in Docker, you need to configure the network so that n8n can connect to Supabase.

解决方案取决于你如何托管这两个组件。

¥The solution depends on how you're hosting the two components.

如果只有 Supabase 在 Docker 容器中#

¥If only Supabase is in Docker

如果 Docker 中仅运行 Supabase,则 自托管指南 使用的 Docker Compose 文件已将 Supabase 绑定到正确的接口。

¥If only Supabase is running in Docker, the Docker Compose file used by the self-hosting guide already runs Supabase bound to the correct interfaces.

配置 Supabase 凭据 时,localhost 地址应该可以正常工作(将主机设置为 localhost)。

¥When configuring Supabase credentials, the localhost address should work without a problem (set the Host to localhost).

如果 Supabase 和 n8n 运行在不同的 Docker 容器中#

¥If Supabase and n8n are running in separate Docker containers

如果 n8n 和 Supabase 都运行在 Docker 的不同容器中,你可以使用 Docker 网络将它们连接起来。

¥If both n8n and Supabase are running in Docker in separate containers, you can use Docker networking to connect them.

配置 Supabase 监听所有接口,方法是将其绑定到容器内的 0.0.0.0(官方的 Docker Compose 配置 已经实现了这一点)。如果你尚未在同一个 Docker Compose 文件中管理 Supabase 和 n8n 组件,请将它们添加到同一个 用户自定义桥接网络 容器中。

¥Configure Supabase to listen on all interfaces by binding to 0.0.0.0 inside of the container (the official Docker compose configuration already does this this). Add both the Supabase and n8n components to the same user-defined bridge network if you aren't already managing them together in the same Docker Compose file.

配置 Supabase 凭据 时,请使用 Supabase API 网关容器的名称(默认为 supabase-kong)作为主机地址,而不是 localhost。例如,如果你使用默认配置,则应将主机设置为 http://supabase-kong:8000

¥When configuring Supabase credentials, use the Supabase API gateway container's name (supabase-kong by default) as the host address instead of localhost. For example, if you use the default configuration, you would set the Host to http://supabase-kong:8000.

记录可通过 Postgres 访问,但无法通过 Supabase 访问#

¥Records are accessible through Postgres but not Supabase

如果使用 Supabase 节点查询记录返回空结果,但通过 Postgres 节点或使用 Postgres 客户端可以访问记录,则可能与 Supabase 的 行级安全性 (RLS) 策略存在冲突。

¥If queries for records return empty using the Supabase node, but are available through the Postgres node or with a Postgres client, there may be a conflict with Supabase's Row Level Security (RLS) policy.

当你使用表格编辑器在公共模式中创建表格时,Supabase 始终启用行级别安全性 (RLS)。启用 RLS 后,在你创建策略之前,API 不会返回任何包含公钥 anon 的数据。这是一项安全措施,旨在确保你只公开你想要公开的数据。

¥Supabase always enables RLS when you create a table in a public schema with the Table Editor. When RLS is active, the API doesn't return any data with the public anon key until you create policies. This is a security measure to ensure that you only expose data you intend to.

要以 anon 角色访问启用了 RLS 的表中的数据,请使用 创建策略 角色启用你计划使用的访问模式。

¥To access data from a table with RLS enabled as the anon role, create a policy to enable the access patterns you intend to use.