pocketbase-db-collection
v0.0.1
Published
Pocketbase collection adapter for TanStack DB
Maintainers
Readme
pocketbase-db-collection
PocketBase adapter for TanStack DB - enables using PocketBase as a data source with TanStack DB.
Installation
npm install pocketbase-db-collection
# or
bun add pocketbase-db-collection
# or
pnpm add pocketbase-db-collectionDependencies
This package requires the following dependencies:
@tanstack/db- The TanStack DB librarypocketbase- The PocketBase client@standard-schema/spec- For schema support@tanstack/store- For internal store
Usage
import { createCollection } from "@tanstack/db"
import { pocketbaseCollectionOptions } from "pocketbase-db-collection"
import PocketBase from "pocketbase"
const pb = new PocketBase("http://localhost:8090")
const recordService = pb.collection("your_collection")
const collection = createCollection(
pocketbaseCollectionOptions({
recordService,
})
)
// Use the collection
await collection.stateWhenReady()
const items = collection.getAll()Development
Prerequisites
- Bun (v1.2.22 or higher)
Install Dependencies
bun installBuild
bun run buildThis generates files in dist/ with both ESM and CJS formats, as well as TypeScript definitions. The build uses bun build directly configured via bunfig.toml.
Tests
bun testDevelopment Mode
bun run devThis runs the build in watch mode.
Publishing to npm
- Make sure the build works:
bun run build - Verify tests pass:
bun test - Update the version in
package.json - Publish:
npm publish
The prepublishOnly script will automatically run before publishing to ensure the build is up to date.
Project Structure
.
├── src/
│ ├── index.ts # Main entry point
│ └── pocketbase.ts # PocketBase adapter implementation
├── tests/
│ └── pocketbase.test.ts # Tests
├── dist/ # Generated files (ESM and CJS)
└── package.jsonLicense
MIT
