supabase-database by nice-wolf-studio/claude-code-supabase-skills
npx skills add https://github.com/nice-wolf-studio/claude-code-supabase-skills --skill supabase-database此技能提供了通过 REST API 操作 Supabase 数据库表的工具。支持带过滤的 SELECT 查询、INSERT、UPDATE、DELETE 操作以及调用 RPC 函数。
必需的环境变量:
export SUPABASE_URL="https://your-project.supabase.co"
export SUPABASE_KEY="your-anon-or-service-role-key"
辅助脚本: 此技能使用共享的 Supabase API 辅助脚本。请确保引入它:
source "$(dirname "${BASH_SOURCE[0]}")/../../scripts/supabase-api.sh"
基本全选:
source "$(dirname "${BASH_SOURCE[0]}")/../../scripts/supabase-api.sh"
# 从表中获取所有行
supabase_get "/rest/v1/your_table?select=*"
选择特定列:
# 仅获取 id 和 name 列
supabase_get "/rest/v1/users?select=id,name,email"
过滤结果:
广告位招租
在这里展示您的产品或服务
触达数万 AI 开发者,精准高效
# 相等过滤
supabase_get "/rest/v1/users?select=*&email=eq.user@example.com"
# 大于
supabase_get "/rest/v1/products?select=*&price=gt.100"
# 小于或等于
supabase_get "/rest/v1/orders?select=*&quantity=lte.10"
# 模式匹配 (LIKE)
supabase_get "/rest/v1/users?select=*&name=like.*John*"
# 在列表中
supabase_get "/rest/v1/products?select=*&category=in.(electronics,books)"
# 为空
supabase_get "/rest/v1/users?select=*&deleted_at=is.null"
排序和限制:
# 按列排序 (升序)
supabase_get "/rest/v1/posts?select=*&order=created_at.asc"
# 按列排序 (降序)
supabase_get "/rest/v1/posts?select=*&order=created_at.desc"
# 限制结果数量
supabase_get "/rest/v1/posts?select=*&limit=10"
# 分页 (偏移量)
supabase_get "/rest/v1/posts?select=*&limit=10&offset=20"
# 范围分页
supabase_get "/rest/v1/posts?select=*" -H "Range: 0-9"
复杂查询:
# 多重过滤 (AND)
supabase_get "/rest/v1/products?select=*&category=eq.electronics&price=gt.100"
# OR 过滤
supabase_get "/rest/v1/users?select=*&or=(status.eq.active,status.eq.pending)"
# 嵌套过滤
supabase_get "/rest/v1/users?select=*,posts(*)&posts.published=eq.true"
插入单行:
source "$(dirname "${BASH_SOURCE[0]}")/../../scripts/supabase-api.sh"
supabase_post "/rest/v1/users" '{
"name": "John Doe",
"email": "john@example.com",
"age": 30
}'
插入多行:
supabase_post "/rest/v1/users" '[
{
"name": "Alice Smith",
"email": "alice@example.com"
},
{
"name": "Bob Jones",
"email": "bob@example.com"
}
]'
Upsert (插入或存在时更新):
# 使用 Prefer: resolution=merge-duplicates 请求头
curl -s -X POST \
"${SUPABASE_URL}/rest/v1/users" \
-H "apikey: ${SUPABASE_KEY}" \
-H "Authorization: Bearer ${SUPABASE_KEY}" \
-H "Content-Type: application/json" \
-H "Prefer: resolution=merge-duplicates" \
-d '{
"id": 1,
"name": "Updated Name",
"email": "updated@example.com"
}'
更新匹配过滤条件的行:
source "$(dirname "${BASH_SOURCE[0]}")/../../scripts/supabase-api.sh"
# 通过 id 更新特定行
supabase_patch "/rest/v1/users?id=eq.123" '{
"name": "Updated Name",
"email": "newemail@example.com"
}'
# 更新多行
supabase_patch "/rest/v1/products?category=eq.electronics" '{
"discount": 10
}'
删除匹配过滤条件的行:
source "$(dirname "${BASH_SOURCE[0]}")/../../scripts/supabase-api.sh"
# 通过 id 删除特定行
supabase_delete "/rest/v1/users?id=eq.123"
# 删除多行
supabase_delete "/rest/v1/logs?created_at=lt.2023-01-01"
执行存储过程:
source "$(dirname "${BASH_SOURCE[0]}")/../../scripts/supabase-api.sh"
# 调用无参数函数
supabase_post "/rest/v1/rpc/function_name" '{}'
# 调用带参数函数
supabase_post "/rest/v1/rpc/calculate_total" '{
"user_id": 123,
"start_date": "2023-01-01",
"end_date": "2023-12-31"
}'
| 操作符 | 描述 | 示例 |
|---|---|---|
eq | 等于 | id=eq.123 |
neq | 不等于 | status=neq.deleted |
gt | 大于 | age=gt.18 |
gte | 大于或等于 | price=gte.100 |
lt | 小于 | quantity=lt.10 |
lte | 小于或等于 | score=lte.50 |
like | 模式匹配 (区分大小写) | name=like.*John* |
ilike | 模式匹配 (不区分大小写) | email=ilike.*@gmail.com |
is | 检查确切值 (null, true, false) | deleted_at=is.null |
in | 在列表中 | status=in.(active,pending) |
not | 否定条件 | status=not.in.(deleted,banned) |
or | 逻辑或 | or=(status.eq.active,status.eq.pending) |
and | 逻辑与 | and=(age.gte.18,age.lte.65) |
美化打印 JSON (需要 jq):
supabase_get "/rest/v1/users?select=*" | jq '.'
提取特定字段:
# 仅获取名称
supabase_get "/rest/v1/users?select=name" | jq -r '.[].name'
统计结果数量:
# 添加 Prefer: count=exact 请求头以获取总数
curl -s -X GET \
"${SUPABASE_URL}/rest/v1/users?select=*" \
-H "apikey: ${SUPABASE_KEY}" \
-H "Authorization: Bearer ${SUPABASE_KEY}" \
-H "Prefer: count=exact" \
-I | grep -i content-range
result=$(supabase_get "/rest/v1/users?select=id&email=eq.test@example.com")
if [[ "$result" == "[]" ]]; then
echo "用户不存在"
else
echo "用户已存在"
fi
# 先检查
existing=$(supabase_get "/rest/v1/users?select=id&email=eq.test@example.com")
if [[ "$existing" == "[]" ]]; then
# 创建新用户
supabase_post "/rest/v1/users" '{
"email": "test@example.com",
"name": "Test User"
}'
echo "用户已创建"
else
echo "用户已存在"
fi
# 处理多条记录
ids=(123 456 789)
for id in "${ids[@]}"; do
supabase_patch "/rest/v1/users?id=eq.$id" '{
"updated_at": "'"$(date -u +%Y-%m-%dT%H:%M:%SZ)"'"
}'
done
辅助脚本会自动处理 HTTP 错误并显示它们。检查返回码:
if supabase_get "/rest/v1/users?select=*"; then
echo "查询成功"
else
echo "查询失败"
exit 1
fi
完整的 Supabase REST API 文档:https://supabase.com/docs/guides/api
每周安装次数
125
代码仓库
GitHub 星标数
10
首次出现
2026年1月22日
安全审计
安装于
claude-code108
opencode103
gemini-cli99
cursor98
codex95
github-copilot89
This skill provides tools for working with Supabase database tables through the REST API. Supports SELECT queries with filtering, INSERT, UPDATE, DELETE operations, and calling RPC functions.
Required environment variables:
export SUPABASE_URL="https://your-project.supabase.co"
export SUPABASE_KEY="your-anon-or-service-role-key"
Helper script: This skill uses the shared Supabase API helper. Make sure to source it:
source "$(dirname "${BASH_SOURCE[0]}")/../../scripts/supabase-api.sh"
Basic select all:
source "$(dirname "${BASH_SOURCE[0]}")/../../scripts/supabase-api.sh"
# Get all rows from a table
supabase_get "/rest/v1/your_table?select=*"
Select specific columns:
# Get only id and name columns
supabase_get "/rest/v1/users?select=id,name,email"
Filter results:
# Equality filter
supabase_get "/rest/v1/users?select=*&email=eq.user@example.com"
# Greater than
supabase_get "/rest/v1/products?select=*&price=gt.100"
# Less than or equal
supabase_get "/rest/v1/orders?select=*&quantity=lte.10"
# Pattern matching (LIKE)
supabase_get "/rest/v1/users?select=*&name=like.*John*"
# In list
supabase_get "/rest/v1/products?select=*&category=in.(electronics,books)"
# Is null
supabase_get "/rest/v1/users?select=*&deleted_at=is.null"
Order and limit:
# Order by column (ascending)
supabase_get "/rest/v1/posts?select=*&order=created_at.asc"
# Order by column (descending)
supabase_get "/rest/v1/posts?select=*&order=created_at.desc"
# Limit results
supabase_get "/rest/v1/posts?select=*&limit=10"
# Pagination (offset)
supabase_get "/rest/v1/posts?select=*&limit=10&offset=20"
# Range pagination
supabase_get "/rest/v1/posts?select=*" -H "Range: 0-9"
Complex queries:
# Multiple filters (AND)
supabase_get "/rest/v1/products?select=*&category=eq.electronics&price=gt.100"
# OR filter
supabase_get "/rest/v1/users?select=*&or=(status.eq.active,status.eq.pending)"
# Nested filters
supabase_get "/rest/v1/users?select=*,posts(*)&posts.published=eq.true"
Insert single row:
source "$(dirname "${BASH_SOURCE[0]}")/../../scripts/supabase-api.sh"
supabase_post "/rest/v1/users" '{
"name": "John Doe",
"email": "john@example.com",
"age": 30
}'
Insert multiple rows:
supabase_post "/rest/v1/users" '[
{
"name": "Alice Smith",
"email": "alice@example.com"
},
{
"name": "Bob Jones",
"email": "bob@example.com"
}
]'
Upsert (insert or update if exists):
# Use Prefer: resolution=merge-duplicates header
curl -s -X POST \
"${SUPABASE_URL}/rest/v1/users" \
-H "apikey: ${SUPABASE_KEY}" \
-H "Authorization: Bearer ${SUPABASE_KEY}" \
-H "Content-Type: application/json" \
-H "Prefer: resolution=merge-duplicates" \
-d '{
"id": 1,
"name": "Updated Name",
"email": "updated@example.com"
}'
Update rows matching filter:
source "$(dirname "${BASH_SOURCE[0]}")/../../scripts/supabase-api.sh"
# Update specific row by id
supabase_patch "/rest/v1/users?id=eq.123" '{
"name": "Updated Name",
"email": "newemail@example.com"
}'
# Update multiple rows
supabase_patch "/rest/v1/products?category=eq.electronics" '{
"discount": 10
}'
Delete rows matching filter:
source "$(dirname "${BASH_SOURCE[0]}")/../../scripts/supabase-api.sh"
# Delete specific row by id
supabase_delete "/rest/v1/users?id=eq.123"
# Delete multiple rows
supabase_delete "/rest/v1/logs?created_at=lt.2023-01-01"
Execute stored procedures:
source "$(dirname "${BASH_SOURCE[0]}")/../../scripts/supabase-api.sh"
# Call function without parameters
supabase_post "/rest/v1/rpc/function_name" '{}'
# Call function with parameters
supabase_post "/rest/v1/rpc/calculate_total" '{
"user_id": 123,
"start_date": "2023-01-01",
"end_date": "2023-12-31"
}'
| Operator | Description | Example |
|---|---|---|
eq | Equals | id=eq.123 |
neq | Not equals | status=neq.deleted |
gt | Greater than | age=gt.18 |
gte |
Pretty print JSON (requires jq):
supabase_get "/rest/v1/users?select=*" | jq '.'
Extract specific field:
# Get just the names
supabase_get "/rest/v1/users?select=name" | jq -r '.[].name'
Count results:
# Add Prefer: count=exact header for total count
curl -s -X GET \
"${SUPABASE_URL}/rest/v1/users?select=*" \
-H "apikey: ${SUPABASE_KEY}" \
-H "Authorization: Bearer ${SUPABASE_KEY}" \
-H "Prefer: count=exact" \
-I | grep -i content-range
result=$(supabase_get "/rest/v1/users?select=id&email=eq.test@example.com")
if [[ "$result" == "[]" ]]; then
echo "User does not exist"
else
echo "User exists"
fi
# Check first
existing=$(supabase_get "/rest/v1/users?select=id&email=eq.test@example.com")
if [[ "$existing" == "[]" ]]; then
# Create new user
supabase_post "/rest/v1/users" '{
"email": "test@example.com",
"name": "Test User"
}'
echo "User created"
else
echo "User already exists"
fi
# Process multiple records
ids=(123 456 789)
for id in "${ids[@]}"; do
supabase_patch "/rest/v1/users?id=eq.$id" '{
"updated_at": "'"$(date -u +%Y-%m-%dT%H:%M:%SZ)"'"
}'
done
The helper script automatically handles HTTP errors and displays them. Check return codes:
if supabase_get "/rest/v1/users?select=*"; then
echo "Query successful"
else
echo "Query failed"
exit 1
fi
Full Supabase REST API documentation: https://supabase.com/docs/guides/api
Weekly Installs
125
Repository
GitHub Stars
10
First Seen
Jan 22, 2026
Security Audits
Gen Agent Trust HubPassSocketPassSnykPass
Installed on
claude-code108
opencode103
gemini-cli99
cursor98
codex95
github-copilot89
Azure 升级评估与自动化工具 - 轻松迁移 Functions 计划、托管层级和 SKU
104,900 周安装
Chrome CDP 命令行工具:轻量级浏览器自动化,无需 Puppeteer,支持多标签页
172 周安装
Supabase Postgres 最佳实践 - 8大优先级规则优化数据库性能与安全
175 周安装
前端设计技能:告别AI生成美学,创建独特、生产级UI界面与代码
172 周安装
ESM蛋白质语言模型:AI驱动蛋白质设计、结构预测与功能分析
176 周安装
PostgreSQL只读查询技能 - 安全连接AI助手执行数据库查询,支持SSL加密与权限控制
179 周安装
Azure Functions 最佳实践指南:独立工作进程、Node.js/Python 编程模型与反模式详解
176 周安装
| Greater than or equal |
price=gte.100 |
lt | Less than | quantity=lt.10 |
lte | Less than or equal | score=lte.50 |
like | Pattern match (case-sensitive) | name=like.*John* |
ilike | Pattern match (case-insensitive) | email=ilike.*@gmail.com |
is | Check for exact value (null, true, false) | deleted_at=is.null |
in | In list | status=in.(active,pending) |
not | Negate a condition | status=not.in.(deleted,banned) |
or | Logical OR | or=(status.eq.active,status.eq.pending) |
and | Logical AND | and=(age.gte.18,age.lte.65) |