pocketbase / js-sdk

PocketBase JavaScript SDK
https://www.npmjs.com/package/pocketbase
MIT License
2.17k stars 127 forks source link

How do I retrieve field values from pocketbase records? #267

Closed ItsTerm1n4l closed 10 months ago

ItsTerm1n4l commented 10 months ago

Im trying to build a website using pocketbase for the backend and svelte for the frontend JS, I have created records like so; 20231212_17h41m13s_grim and I need to get the value of the name field of all the records in the parts collection and display them in a dropdown box in my site, how do I do this? Thank You.

ganigeorgiev commented 10 months ago

You can call getList() (for paginated records list) or getFullList() (for all collection records):

const records = await pb.collection("parts").getFullList();

Note that by default new collections have "Admin only" API rules. You can manage the permissions to your collection from the collection settings (cogwheel) > API rules.

For more details and examples you can explore the "API Preview" section of the collection or explore the generic web API docs at https://pocketbase.io/docs/api-records/.

If you need further help, for general PocketBase usage questions please consider opening a Q&A discussion instead.