prime icon indicating copy to clipboard operation
prime copied to clipboard

Querying by subdocuments

Open MichalLytek opened this issue 6 years ago • 2 comments

I would like to search by subdocuments. I have an author in the blogPost type and I would like to get all posts by selected author.

image

Where I can dig in to add a support for this kind of feature?

MichalLytek avatar Mar 22 '19 10:03 MichalLytek

Hey

Good feature request.

You can add a whereType to the document field: https://github.com/birkir/prime/blob/master/packages/prime-field-document/src/PrimeFieldDocument.ts

Good template is the group field: https://github.com/birkir/prime/blob/master/packages/prime-field-group/src/PrimeFieldGroup.ts

If you need to add something to the where builder: https://github.com/birkir/prime/blob/master/packages/prime-core/src/modules/external/utils/documentWhereBuilder.ts

Let me know if you need help!

birkir avatar Mar 22 '19 13:03 birkir

Hey @birkir !

We're trying to implement this very feature for our usage of prime (to find articles by a given category, categories being contentTypes of their own, and considering categories could be multiple).
I've managed to define the whereType, but I'm having a hard time listing the fields, and connecting the dots in the query to get the right results, I think I'm missing too many bits of code here and there.
I tried looking at what prismic is doing, but they don't seem to be relying on the same logic (I'm seeing linked documents in their doc), so I'm a little clueless.

Can I ask you for a little more direction? Thanks!

vcervellera-turbulent avatar Jul 09 '19 18:07 vcervellera-turbulent