diff options
| author | Alex Pooley (@zuedev) <zuedev@gmail.com> | 2026-07-21 23:02:52 +0100 |
|---|---|---|
| committer | Alex Pooley (@zuedev) <zuedev@gmail.com> | 2026-07-21 23:02:52 +0100 |
| commit | da0509c91376f56f133872eddd2e4282d76f215e (patch) | |
| tree | 7d39fb76ab89855d17fab28ca7e000b3acd9a89d /174bg/discord-bot/controllers/pocketbase.js | |
| parent | 764f90577eeadd653f3f6248fbf2b0918c97a3d5 (diff) | |
| download | unnamed-group-da0509c91376f56f133872eddd2e4282d76f215e.tar unnamed-group-da0509c91376f56f133872eddd2e4282d76f215e.tar.gz unnamed-group-da0509c91376f56f133872eddd2e4282d76f215e.tar.bz2 unnamed-group-da0509c91376f56f133872eddd2e4282d76f215e.tar.xz unnamed-group-da0509c91376f56f133872eddd2e4282d76f215e.zip | |
more org changes
Diffstat (limited to '174bg/discord-bot/controllers/pocketbase.js')
| -rw-r--r-- | 174bg/discord-bot/controllers/pocketbase.js | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/174bg/discord-bot/controllers/pocketbase.js b/174bg/discord-bot/controllers/pocketbase.js index b808ce4..4046391 100644 --- a/174bg/discord-bot/controllers/pocketbase.js +++ b/174bg/discord-bot/controllers/pocketbase.js @@ -1,17 +1,35 @@ +/** + * Controller module for interacting with the PocketBase API. + */ + import PocketBase from "pocketbase"; const { POCKETBASE_URL, POCKETBASE_SUPERUSER_EMAIL, POCKETBASE_SUPERUSER_PASSWORD } = process.env; +/** + * Logs in to the PocketBase API using the superuser credentials. + * @returns {Promise<PocketBase>} A Promise that resolves to the authenticated PocketBase instance. + */ export async function login() { const pb = new PocketBase(POCKETBASE_URL); await pb.collection("_superusers").authWithPassword(POCKETBASE_SUPERUSER_EMAIL, POCKETBASE_SUPERUSER_PASSWORD); return pb; } +/** + * Logs out of the PocketBase API by clearing the authentication store. + * @param {PocketBase} pb - The PocketBase instance to log out from. + * @returns {Promise<void>} A Promise that resolves when the logout is complete. + */ export async function logout(pb) { await pb.authStore.clear(); } +/** + * Retrieves the full list of records from a specified collection in the PocketBase API. + * @param {string} collectionName - The name of the collection to retrieve records from. + * @returns {Promise<RecordModel[]>} A Promise that resolves to an array of records from the specified collection. + */ export async function getFullList(collectionName) { const pb = await login(); const data = await pb.collection(collectionName).getFullList(); |
