47 lines
1.4 KiB
TypeScript
47 lines
1.4 KiB
TypeScript
|
|
import "./_env";
|
||
|
|
import { getAdminPocketBase } from "../src/lib/server/pocketbase-admin";
|
||
|
|
|
||
|
|
async function main() {
|
||
|
|
const pb = await getAdminPocketBase();
|
||
|
|
const total = await pb.collection("stock_items").getList(1, 1, { filter: "" });
|
||
|
|
const nss = await pb.collection("stock_items").getList(1, 5, {
|
||
|
|
filter: 'location = "NSS Fasteners price list - hex nut DIN934 (Grade 8 + A2)"',
|
||
|
|
});
|
||
|
|
const active = await pb.collection("stock_items").getList(1, 1, {
|
||
|
|
filter: 'supplier = "6xuu7a0pmmubtqd" && is_active = true',
|
||
|
|
});
|
||
|
|
|
||
|
|
console.log("Total stock_items in PB: " + total.totalItems);
|
||
|
|
console.log("NSS-imported rows: " + nss.totalItems);
|
||
|
|
console.log("NSS supplier active count: " + active.totalItems);
|
||
|
|
console.log("\nSample imported row:");
|
||
|
|
const sample = nss.items[0];
|
||
|
|
console.log(
|
||
|
|
JSON.stringify(
|
||
|
|
{
|
||
|
|
sku: sample.sku,
|
||
|
|
name: sample.name,
|
||
|
|
description: sample.description,
|
||
|
|
cost_price: sample.cost_price,
|
||
|
|
selling_price: sample.selling_price,
|
||
|
|
markup: sample.markup,
|
||
|
|
unit: sample.unit,
|
||
|
|
location: sample.location,
|
||
|
|
supplier: sample.supplier,
|
||
|
|
category: sample.category,
|
||
|
|
is_active: sample.is_active,
|
||
|
|
cost_history_len: Array.isArray(sample.cost_history)
|
||
|
|
? sample.cost_history.length
|
||
|
|
: 0,
|
||
|
|
},
|
||
|
|
null,
|
||
|
|
2,
|
||
|
|
),
|
||
|
|
);
|
||
|
|
}
|
||
|
|
|
||
|
|
main().catch((e) => {
|
||
|
|
console.error(e);
|
||
|
|
process.exit(1);
|
||
|
|
});
|