stable
pinia
Pinia store factory — defineNoydbStore<T>() gives a typed, reactive, SSR-safe encrypted store with a chainable query() and schema validation.
@noy-db/in-pinia·pnpm add @noy-db/in-pinia @noy-db/hub pinia vuePinia integration for noy-db — drop-in encrypted Pinia stores for Vue 3 / Nuxt 4.
What it does
defineNoydbStore<T>(name, { compartment, schema? }) returns a real Pinia
store exposing items (reactive array), count, $ready (resolves after
first hydration), byId(id), add / update / remove, refresh(), and
a chainable query() — the same query DSL as Collection.query().
setActiveNoydb(db) wires the underlying Noydb instance once at app
startup. storeToRefs, Vue Devtools, SSR hydration, and
pinia-plugin-persistedstate all work unmodified. Pass any object with
parse(input): T (Zod, Valibot, …) as schema — add() / update()
throw on validation failure before any encryption happens.
Usage
// stores/invoices.ts
import { defineNoydbStore } from '@noy-db/in-pinia'
export const useInvoices = defineNoydbStore<Invoice>('invoices', { compartment: 'C101' })
const invoices = useInvoices()
await invoices.$ready
const overdue = invoices.query().where('status', '==', 'open').orderBy('dueDate').toArray()
See also
- in-* family
- vue — the composables
in-piniabuilds on - nuxt — auto-imports
defineNoydbStorefor you