0.1.1 • Published 9 months ago

trinn-pocketbase-store v0.1.1

Weekly downloads
-
License
MIT
Repository
-
Last release
9 months ago

Trinn Svelte Store

This package wraps pocketbase and svelte together to create one beautiful union.

Note: for right now this is read-only. Updating is planned for later.

Usage

You NEED to use Svelte and have an instance of PocketBase you can access.

//You always have to connect to a PB instance first. Username and password are optional.
await PBWritable.connect("POCKETBASE_URL", "USERNAME", "PASSWORD");

//You can create a store for a single record
const [word, updateWord] = await PBWritable.create<Word>(
  "COLLECTION_NAME",
  "RECORD_ID"
);
updateWord({ word: "some change" });

//You can create a store for a complete collection (beware, when the collection changes it is COMPLETELY redownloaded)
const [words, updateWord, createWord, removeWord] = await PBWritable.createList<
  Word[]
>("COLLECTION_NAME");

//For lists you can use the existing RecordListOptions from Pocketbase, like filter, sort, etc.
const [lastWords, updateLastWord, createLastWord, removeLastWord] =
  await PBWritable.createList<Word[]>("COLLECTION_NAME", {
    sort: "-word",
    page: 1,
    perPage: 10,
  });
0.1.1

9 months ago

0.0.3

9 months ago

0.0.2

9 months ago

0.0.1

9 months ago