https://github.com/ahme-dev/pocketbase-expandless
Library to remove expands from pocketbase records.
https://github.com/ahme-dev/pocketbase-expandless
pocketbase
Last synced: 9 months ago
JSON representation
Library to remove expands from pocketbase records.
- Host: GitHub
- URL: https://github.com/ahme-dev/pocketbase-expandless
- Owner: ahme-dev
- License: mit
- Created: 2023-03-05T15:36:19.000Z (over 3 years ago)
- Default Branch: master
- Last Pushed: 2023-03-15T13:55:46.000Z (over 3 years ago)
- Last Synced: 2025-03-01T18:37:35.338Z (over 1 year ago)
- Topics: pocketbase
- Language: TypeScript
- Homepage: https://www.npmjs.com/package/pocketbase-expandless
- Size: 35.2 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE.md
Awesome Lists containing this project
README
### Pocketbase Expandless



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:
```typescript
product.expand.category_id;
transaction.expand.product_id.expand.category_id;
```
Into an easier way:
```typescript
product.category_id;
transaction.product_id.category_id;
```
### Install
```bash
npm i pocketbase-expandless
```
### Usage
```typescript
// 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)
})
```