How to return/filter by a multi reference field when querying

Having an issue filtering a collection because not all fields are returned when querying the collection.

import wixData from "wix-data";
function filter(category) { 
    $w('#postsDataset').setFilter(wixData.filter().contains('categories', category))
}   

The ‘categories’ field exists in the collection but doesn’t seem to be returned when querying and I don’t understand why

Sample of first item in database returned when using wixData.query
:"{"excerpt":"Start by trying to move just the tip of your pointer finger","_id":"4e16ec51-d00a-4925-af81-ce8028525f48","_owner":"45085031-cb3a-4f5e-b5f3-9bcfac3a4f3f","_createdDate":"2020-09-20T20:27:17.765Z","_updatedDate":"2020-09-21T03:59:30.277Z","plainContent":

The multi-referenced fields are not called when queying an item, for that you have to do a second query of query-reference

Can you give me an example or explain in more detail please?

@johnmiko4 chek the api :slight_smile:
https://www.wix.com/corvid/reference/wix-data/queryreferenced

@miguelhongo90 great thanks so much. Sorry for being dumb, just assumed the collection I had was the same as a SQL table with a foreign key to Categories

@miguelhongo90 I’m still having trouble with this. Queryreferenced only works with a specific item. I want to filter an entire dataset based on a reference field but can’t figure out how to combine include() and filter(). Figure it’s something close to this

 let query = wixData.query('posts')
        .include('categories')
        .eq('_id', category)
        .find();
    $w("#postsDataset").setFilter(wixData.filter(query));

Follow this thread, you can get some hints. Keep in mind the limitations of the length. (its a bit headache)
https://www.wix.com/corvid/forum/community-discussion/queryreferenced-result-limited-to-50?origin=member_comments_page

Umm could we ask for further help … sample code may be !?