PocketBase

Build backends with PocketBase collections, auth, and realtime.

Safety Notice

This listing is from the official public ClawHub registry. Review SKILL.md and referenced scripts before running.

Copy this and send it to your AI assistant to learn

Install skill "PocketBase" with this command: npx skills add ivangdavila/pocketbase

SDK Basics

  • Import from pocketbase not pocketbase/dist — the dist path is internal and breaks on updates
  • Always check pb.authStore.isValid before using pb.authStore.model — expired tokens return stale data without error
  • After login, token is auto-attached to requests — no need to manually set Authorization headers

Fetching Records

  • Use expand parameter to load relations: pb.collection('posts').getList(1, 20, { expand: 'author,comments' })
  • Expanded records appear in record.expand.fieldName — not directly on the record object
  • Filter syntax is SQL-like but uses single quotes: filter: "status = 'active' && created >= '2024-01-01'"
  • Combine conditions with && and ||, not AND/OR — SQL keywords don't work

Authentication

  • Users collection is users (lowercase) — _users or Users returns empty results
  • authWithPassword(email, password) returns the full user record plus token
  • OAuth flow: authWithOAuth2({ provider: 'google' }) opens popup automatically in browser
  • Logout requires both pb.authStore.clear() and invalidating server-side if using tokens elsewhere

Realtime

  • Subscribe with pb.collection('posts').subscribe('*', callback) — the '*' means all record changes
  • Callback receives { action: 'create'|'update'|'delete', record } — check action before processing
  • Always unsubscribe on cleanup: pb.collection('posts').unsubscribe() — orphan subscriptions leak memory

File Uploads

  • Files require FormData, not JSON: formData.append('document', file) then pass to create()
  • Get file URL with pb.files.getURL(record, record.filename) — don't construct URLs manually
  • Multiple files to same field: append with same key multiple times

Collection Rules

  • Empty rule = blocked for everyone, "" (empty string) rule = open to everyone — counterintuitive
  • Use @request.auth.id to reference logged-in user, @request.data for submitted data
  • Example restrict to owner: @request.auth.id = user.id in View/Update/Delete rules

Hooks (pb_hooks/)

  • JavaScript hooks go in pb_hooks/*.pb.js — the .pb.js extension is required
  • Hooks run synchronously and block the request — keep them fast or use routines
  • Access app with $app, event data with e — common: e.record, e.httpContext

Admin API

  • Admin endpoints need superuser auth, not regular user tokens
  • Create admin token: pb.admins.authWithPassword(email, password)
  • Admin operations use pb.admins or pb.collections, not pb.collection()

Source Transparency

This detail page is rendered from real SKILL.md content. Trust labels are metadata-based hints, not a safety guarantee.

Related Skills

Related by shared tags or category signals.

General

Charging Ledger

充电记录账本 - 从截图提取充电信息并记录,支持按周、月查询汇总。**快速暗号**: 充电记录、充电账本、充电汇总。**自然触发**: 记录充电、查询充电费用、充电统计。

Registry SourceRecently Updated
General

qg-skill-sync

从团队 Git 仓库同步最新技能到本机 OpenClaw。支持首次设置、定时自动更新、手动同步和卸载。当用户需要同步技能、设置技能同步、安装或更新团队技能,或提到「技能同步」「同步技能」时使用。

Registry SourceRecently Updated
General

Ad Manager

广告投放管理 - 自动管理广告投放、优化ROI、生成报告。适合:营销人员、电商运营。

Registry SourceRecently Updated