Boo
07/28/2022, 1:29 AMorderBy the combined result?
Meaning...
.findFirst({
where: {
id: 1
}, {
select: {
something: {...},
somethingElse: {...}
}
}
})
so combining something and somethingElse within here and then orderBy both of them all in one query, including paginationDave Edelhart
07/28/2022, 3:30 AMsomething.findFirst({
where { foo.id: 1}
take: 4,
skip: 5,
});
You cannot take multiple tables and treat them as a single set of records in SQL without a significant restrictions (https://www.postgresqltutorial.com/postgresql-tutorial/postgresql-union/).
You can do so procedurally by
1. creating a temporary table with fields that accept values from both sources (and maybe a “source_table” field for reference)
2. dumping data from two queries into the temp table and
3. querying it;
however the temporary table will not persist across queries, meaning, the net work is a lot greater than simply pulling all the relevant data into javaScript and paginating it.
A third option is to
1 create a permanent denormalized table with fields that accept values from both sources
2 dumping all relevant data into it and
3. querying the denormed table
but the basic problem here is you are dealing with a grid-based system and trying to make it act like a polymorphic class — that is going to take a significant amount of carrying by you.