Skill站外收录 @skilllib/skill-2014279417898414081
supabase-usage
提供对 Supabase 数据库的结构化访问能力,支持数据库模式查询、表关系分析与安全策略配置,适用于实现细粒度数据权限控制、高效查询设计及规范化数据交互逻辑。
数据库 AI 技能
Skills.MD
# Supabase Database Patterns
Patterns for working with Supabase databases including Auth, Row Level Security, table relationships, and query best practices.
## Overview
- **MCP Tools**: Query and explore database structure
- **Authentication**: User management, sessions, auth tables
- **Row Level Security**: Policy patterns for data access control
- **Table Relationships**: Foreign keys, joins, nested queries
- **Query Patterns**: Filtering, pagination, performance
## MCP Tools
Available tools for database exploration:
- `mcp__supabase__list_tables` - List all tables in the database
- `mcp__supabase__get_table_schema` - Get schema for a specific table
- `mcp__supabase__execute_sql` - Run read-only SQL queries
**Workflow:**
1. Start with `list_tables` to understand database structure
2. Use `get_table_schema` to inspect columns and types
3. Use `execute_sql` for custom queries (read-only)
---
## Best Practices
### DO
- ✓ Enable RLS on all public tables
- ✓ Use `(select auth.uid())` in RLS policies for performance
- ✓ Add indexes on RLS-checked columns
- ✓ Specify roles with `TO authenticated` in policies
- ✓ Use `on delete cascade` for foreign keys to auth.users
- ✓ Use cursor-based pagination for large datasets
- ✓ Select only needed columns: `.select('id, name')` not `.select('*')`
### DON'T
- ✗ Store sensitive data without RLS
- ✗ Use `auth.uid()` directly in policies (use `(select auth.uid())`)
- ✗ Create policies without specifying roles
- ✗ Forget indexes on frequently filtered columns
- ✗ Use offset pagination for deep pages (>1000 rows)
- ✗ Expose auth.users directly via API (use public profiles table)
---
## Quick Reference
### Common Filters
| Filter | JavaScript | Python |
| ---------------- | ------------------------ | ------------------------ |
| Equals | `.eq('col', val)` | `.eq("col", val)` |
| Not equals | `.neq('col', val)` | `.neq("col", val)` |
| Greater than | `.gt('col', val)` | `.gt("col", val)` |
| Greater or equal | `.gte('col', val)` | `.gte("col", val)` |
| Less than | `.lt('col', val)` | `.lt("col", val)` |
| Less or equal | `.lte('col', val)` | `.lte("col", val)` |
| Pattern match | `.ilike('col', '%val%')` | `.ilike("col", "%val%")` |
| In list | `.in('col', [a,b])` | `.in_("col", [a,b])` |
| Is null | `.is('col', null)` | `.is_("col", "null")` |
| OR | `.or('a.eq.1,b.eq.2')` | `.or_("a.eq.1,b.eq.2")` |
### Auth Tables Quick Reference
| Table | Key Columns |
| ----------------- | ----------------------------------------------------------------- |
| `auth.users` | id, email, phone, created_at, last_sign_in_at, raw_user_meta_data |
| `auth.sessions` | id, user_id, created_at, updated_at |
| `auth.identities` | id, user_id, provider, identity_data |
### RLS Policy Template
```sql
create policy "policy_name" on table_name
to authenticated -- or anon, or specific role
for select -- select, insert, update, delete, or all
using ( (select auth.uid()) = user_id )
with check ( (select auth.uid()) = user_id ); -- for insert/update
```
---
## Additional Resources
For detailed patterns and code examples, consult:
- **`references/auth.md`** - Authentication with JS/Python SDK, user profiles
- **`references/rls.md`** - Row Level Security policies and performance tips
- **`references/relationships.md`** - Table relationships and nested queries
- **`references/query-patterns.md`** - Filtering, pagination, counting, indexes
评论 0
还没有评论,来抢沙发。
相关内容
同类或同场景的收录内容
building-with-kafka-strimzi
在 Kubernetes 上构建基于 Apache Kafka 的事件驱动系统,支持高可靠的消息传递、事务性处理与精确一次语义,结合 Strimzi 运营商实现集群自动化管理,利用 Schema Registry 保障事件模式演进,适用于微服务间解耦通信与实时数据流处理场景。
站外数据与分析
609 0.0
personal-tool-builder
专注于从个人真实痛点出发快速构建实用工具,涵盖命令行程序、本地优先应用和自动化脚本的开发与演进,强调先满足自身需求再逐步扩展,通过持续自用打磨功能,避免过度设计,确保工具简洁有效且长期可维护。
站外商业与营销
196 0.0
threejs-lighting
实现三维场景中的光照与阴影控制,支持多种光源类型及环境光照明,提供从基础布光到高级阴影优化的完整方案,适用于需要真实感渲染或性能平衡的可视化项目。
站外效率工具
442 0.0
aggregation-helper
提供数据聚合场景的自动化辅助能力,涵盖 SQL 查询编写、统计分析建模、可视化方案设计及商业智能配置,支持从需求理解到生产级代码生成的全流程指导。
站外效率工具数据与分析
217 0.0
举报「supabase-usage」
举报信息仅审核团队可见,同一资产 24 小时内仅可举报一次