pocketbase-expandless
TypeScript icon, indicating that this package has built-in type declarations

0.5.0 • Public • Published

npm npm bundle size

This library is made to remove expands from pocketbase records, and instead set the properties inside of them as the record's properties.

This means that the regular way to access expanded fields will change from:

product.expand.category_id;

transaction.expand.product_id.expand.category_id;

Into an easier way:

product.category_id;

transaction.product_id.category_id;

Install

npm i pocketbase-expandless

Usage

// import the main function from the the library
import { moveExpandsInline } from "pocketbase-expandless";

// fetch your data as you would
let transactions = await pb.collection("transactions").getList(1, 25, {
	expand: "transaction_product_ids.product_id.category_id, customer_id",
});

// give the list of items to the function and get a list without expands
const itemsExpandless = moveExpandsInline(transactions.items);

// use the items as you want
items.map((item) => {
	console.log("category with no expand = ", item.product_id.category_id);
});

Readme

Keywords

Package Sidebar

Install

npm i pocketbase-expandless

Weekly Downloads

2

Version

0.5.0

License

MIT

Unpacked Size

5.52 kB

Total Files

6

Last publish

Collaborators

  • ahmeddots