JEI_Import_Documents-App/scripts/debug_pb_fields.mjs
Mavis 44f9b6957e fix: bypass Next.js fetch-cache for PB SDK calls
Next.js patches the global fetch with a cache layer that was returning
stale PB responses (showing description_goods as the code itself because
the snapshot was from before the import fixed the descriptions).

Wrap the SDK with a custom fetch using cache: no-store so every page
request gets fresh data from PocketBase.
2026-09-17 23:59:13 +02:00

14 lines
571 B
JavaScript

// Debug: see what fields PB SDK returns
import { default as PocketBase } from 'pocketbase';
import fs from 'fs';
const env = fs.readFileSync('.env.local', 'utf8');
const token = env.match(/PB_TOKEN=(.+)/)[1].trim();
const url = env.match(/PB_URL=(.+)/)[1].trim();
const pb = new PocketBase(url);
pb.authStore.save(token);
(async () => {
const r = await pb.collection('JEI_stock_codes').getList(1, 3, { sort: 'code' });
console.log('first item keys: ' + Object.keys(r.items[0]).join(', '));
console.log('first item: ' + JSON.stringify(r.items[0], null, 2));
})();