Getting Started

Introduction

Build type-safe PocketBase queries using TypeScript.

Flexible and strongly-typed, with useful helpers to simplify the querying process.

Features

  • 💬 Full TypeScript Integration: Get autocompletion for fields and type safety based on your schema.
  • 📖 Built-in Documentation: Get examples and explanations directly in your IDE with JSDoc.
  • 🔗 Chainable API: Easily build complex queries using a functional, intuitive syntax.
  • 🛡️ Injection Protection: Automatically sanitize queries with pb.filter().
  • 🧩 Nested Grouping: Create advanced logic with .group().
  • 📅 Date & Array Support: Seamlessly work with dates and array operations.
  • 🔍 Advanced Search: Perform multi-field searches with a single method call.
  • ⚡ Helper Operators: Use built-in helpers like .search(), .between(), .in(), .isNull(), and more.
  • 🪝 Works Everywhere: Use queries both in your app and inside pb_hooks.
You can use this package without TypeScript, but you would miss out on many of its advantages.

Why pb-query?

Our goal was to build a flexible and strongly-typed query builder with useful helpers to simplify the querying process. But more importantly, we wanted to create a tool that helps prevent errors and provides examples and solid autocompletion in the IDE. This way, when we come back to the project after a long time, we won't need to relearn the intricacies of PocketBase's querying syntax.

Code Suggestions and JSDoc

Documentation directly in your IDE.

Leveraging the power of TypeScript, we provide suggestions based on your schema.

Credits

This project was inspired by @emresandikci/pocketbase-query.

@sergio9929/pb-query is maintained by @sergio9929 with ❤️