PocketBase list all records in a collection

When using the getList() method to fetch queries from your collection, you can run into issues where as your database grows, you are no longer collecting all the records. To fix this you can use the getFullList method.


getFullList is a method of the collection used to fetch the entire contents of a collection. It returns when all the records are fetched. It takes two arguments, the first is the batch size and the second one is the sort/filter object. The batch size is the number of records to fetch at a time. Regardless of the batch size, all the records will be fetched, but the batch size does affect how long the function takes to return all of the records. If your records contain a lot of data in each one, I would recommend setting the batch size lower so as to not error out each request, but if your records are fairly small, it is best to set the batch size higher. Below is an example of using the getFullList method to fetch records out of a collection name posts.

const results = await pb.collection('posts').getFullList(200, {
            filter: `author = "${user.id}"`

The output will be different from the .getList method, which returns an object with the records being stored in .items. Instead, it will return an array with all of your records.



Be the first to comment!

Read More

Node JS Logo
Node JS Logo

Setting up Node.JS for production

Node.js is a popular JavaScript runtime that allows developers to build server-side applications with JavaScript. PM2 is a process manager for Node.js applications that helps to keep your applications running smoothly and automatically restart th...

Understanding Classes in JavaScript

Classes are blueprints for creating objects (a type of data structure), providing initial values for state (using a constructor), and implementations of behavior (member functions or methods). They ...

Node JS Express Server

Even though Node JS has a built in HTTP request handler using a web server framework can reduce the amount of code and increase the reliability of your site. There are many options to ...