E.g. If I want to fetch all pages and all users. Could that be done with one API call?
👍
ok so there are a few options
short answer, Payload doesn't do anything like that out of the box
but longer answer - you could open up a custom endpoint and use a MongoDB
aggregatequery that merges content from multiple collections into a single result set
OR, you could build some type of "search" collection
take a look at hope network's search functionality:
this site uses a collection called
SearchOk thanks. I will investigate the custom endpoint route with MongoDb.
and then every collection that we want to search across has an
afterChangehook, that syncs it to the
searchcollection
so then the frontend of the hope site just queries against the
searchcollection, and then documents from like 6 collections all get returned
in a very fast / performant way
this is good if you just need a quick solution. but another thing to look into, if you are going to be doing heavy searches, and you need it to scale with thousands of docs, is to use Algolia or similar
Cool, cheers
@364124941832159242Star
Discord
online
Get dedicated engineering support directly from the Payload team.