API query order by field across multiple custom types

From the documentation it states we can either order by 2 methods.

 The paths can take two formats, based on the predicate: document.{first/last_publication_date} or my.{custom-type}.{field}.

Is it possible to order across multiple custom-types (that have the same field) ?

Thanks,

Pete

Hi @pculley,

Thanks for posting this question. Fields are specific to Custom Types, so you can't order by fields in the API.

Alternatively, I would suggest a workaround:

You can query multiple Custom Types with the any predicate. Then, in your code, you can sort the results with Array.sort().

The downside is that, if you have more than 100 matching documents, you'll need to perform a recursive query to fetch them all. However, v6 of @prismicio/client is currently in alpha, and it has a getAll method, which performs a recursive function. So, you could do something like:

await client.getAll({
  predicates: prismic.predicate.any(["type-a", "type-b", "type-c"])
})

That will return an array of all documents of Type A, Type B, and Type C, which you can sort.

The beta documentation for the v6 package will be out in the coming days.

Sam

Thanks Sam,

any ETA on a stable release of the v6 client?

Pete

@pculley We'll probably move it to beta in the next few days, but we don't have an ETA for stable. It's already been tested, so the beta period will be more so for communications, updating documentation, and gathering feedback on features. I hope that helps.