Searching from PostgreSQL base

28 Views Asked by At

I have a UICollectionView that makes requests to backend every 20 rows to fetch data (http://0.0.0.0:8999/GrnknOknCond/get-all?limit=20&page=0 this type of way).

Is it possible to add a UISearchBar and set up the Delegate function in any way to be able to search trout the DB before loading all of the rows into the UICollectionView?

this is how the rows are loaded

extension ObjectsListViewController: UICollectionViewDelegate {

    func collectionView(_ collectionView: UICollectionView, willDisplay cell: UICollectionViewCell, forItemAt indexPath: IndexPath) {
        if indexPath.section + 1 == objectsListService.objects.count {
            objectsListService.fetchObjectsNextPage(ofModel: pickedModel)
        }
    }
}

it fetches the objects into objects array on the ObjectsListService class. There's an observer, so the new objects automatically get added to the objects property of the view controller that makes up the collection view (it gets updated with batch updates)

there are sometimes thousands of objects so it would obviously take years to just scroll to the bottom of the CollectionView, so I need to set up a search bar to be able to find the necessary object... is it possible without first uploading all the objects?

basically search through the base and only get the adequate objects...

Or is it the backend task?

0

There are 0 best solutions below