Predicate with path "my.[custom-ype].[contentRelionShipField].link.uid"

Hi,

I am trying to retrieve all the custom-types "artwork" linked to a custom-type "collection".
This link exist through a content relonalship field edited in the "artwork" custom-types.

So, on collection/[uid] page (next.js project), I tried this:

const myCollection = await client.getByUID("collection", params.uid);
const myCollectionUid = collection.uid;

const artworksPaginatedForMyCollection = await client.get({
            predicates: [
                prismic.predicate.at("document.type", "artwork"),
                prismic.predicate.at( "my.artwork.collection.link.uid", myCollectionUid )
            ],
            pageSize: 20,
            page: 1,
            orderings: {
                field: 'my.artwork.createdDate',
                direction: 'desc',
            },
    })

But the predicate path is unexpected.
I don't find on the documentation an other solution to make similar...

Hello @dev35

Welcome to the Prismic community, and thanks for reaching out to us.

To query by Content Relationship, use the at predicate with the path my.[custom-type].[content-relationship-field] and the ID of the linked document. The ID is a randomly generated string: WNje3SUAAEGBu8bc. You can find it in the metadata of document's API result.

Give this a try, and let me know if you have any further questions.

Thanks,
Priyanka

Yep. It's work.

 const collectionId = collection?.id;
    const artworksPaginated = await client.get(
        {
            predicates: [
                prismic.predicate.at("document.type", "artwork"),
                prismic.predicate.at("my.artwork.collection.link", collectionId)
            ]
        }
    )

Thank you for the quick response and my apologies for the late thank you.

No problem, @dev35 I am glad that It works. Feel free to reach out to us if you have any further questions.