0.5.0 • Published 1 year ago

pocketbase-expandless v0.5.0

Weekly downloads
-
License
MIT
Repository
github
Last release
1 year ago

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);
});
0.5.0

1 year ago

0.4.0

1 year ago

0.3.4

1 year ago

0.3.3

1 year ago

0.3.2

1 year ago

0.3.1

1 year ago

0.3.0

1 year ago

0.2.3

1 year ago

0.2.2

1 year ago

0.2.1

1 year ago

0.2.0

1 year ago

0.1.0

1 year ago