@enokas/pb_cli
A command-line interface tool for managing PocketBase collections and profiles.
Installation
npm install -g @enokas/pb_cli
pnpm add -g @enokas/pb_cli
yarn global add @enokas/pb_cli
Usage
pb_cli profile add myapp http://localhost:8090 admin@example.com mypassword
pb_cli list users --filter "created >= '2023-01-01'"
pb_cli modify update users -f "active = false" -d '{"active": true}'
pb_cli modify delete logs -f "created < '2023-01-01'" --dry-run
pb_cli create users -d '{"name": "John Doe", "email": "john@example.com"}'
pb_cli send POST http://localhost:8090/api/endpoint -h '{"Content-Type": "application/json"}' -d '{"key": "value"}'
Features
- Profile Management: Create and manage multiple PocketBase profiles
- List Records: Query and display records from any collection
- Modify Records: Update or delete records in bulk with filters
- Create Records: Add new records to any collection
- Send Custom Requests: Make custom requests with method, custom header (including token), and custom data
- Dry Run: Preview changes before applying them
Commands
Profile Management
profile add <name> <url> <email> <password>
: Add a new profile
profile list
: List all profiles
profile use <name>
: Switch to a profile
profile remove <name>
: Remove a profile
List Records
list <collection> [options]
: List records from a collection
-f, --filter <filter>
: Filter expression
-s, --sort <sort>
: Sort expression
--fields <fields>
: Comma-separated list of fields to display
--page <page>
: Page number
--per-page <count>
: Records per page
Modify Records
Create Records
create <collection> [options]
: Create a new record
-d, --data <json>
: JSON data for the new record
Send Custom Requests
send <method> <url> [options]
: Send a custom request
-h, --headers <headers>
: Custom headers as JSON string
-d, --data <data>
: Request data as JSON string
Script Execution
script <path>
: Execute a JSON script containing multiple PocketBase operations
- The script file should be a JSON file with the following structure:
{
"run": [
{
"create": [
{
"collection": "users",
"data": { "name": "John Doe", "email": "john@example.com" }
}
],
"list": [
{
"collection": "users",
"options": {
"filter": "created >= '2023-01-01'",
"sort": "-created"
}
}
],
"modify": [
{
"type": "update",
"collection": "users",
"filter": "active = false",
"data": { "active": true }
}
],
"send": [
{
"method": "POST",
"url": "http://localhost:8090/api/endpoint",
"headers": { "Content-Type": "application/json" },
"data": { "key": "value" }
}
]
}
]
}
License
MIT