Multi reference - a basic question

I couldn’t find anything about it in the documentation, but it’s so basic question that I guess it has been asked many times before (sorry for boring you).
So -
If I have a single reference field, I can get the reference Id with a regular query (no need to use .include() unless I want to retrieve other fields from the “joined” collection).

Therefore, I expected that in a case of a multi-reference field, I’ll get an array of reference Id’s without having to use .include() . After all, I only need the the IDs which are linked to the current collection.

However, that doesn’t work. It seems like the query just doesn’t retrieve this reference field at all, and I’m wondering why.

Thanks,

I’m not sure what you want to achieve, but if you want to get the IDs of all the references in a field.
To somethink like that:

// Get Multi-Item Reference ID
async function getReferenceID(database, referenceField) {
 const res = await wixData.query(database)
        .include(referenceField)
        .find();
 return  res.items.map(e => e._id );
} 

I know I can do it. But if I query collection A that includes a reference field to collection B.
It looks unreasonable to have to get the full items from collection B while all I need is the ID that are already linked to collection A.
Also in this case, I’ll not be able to work with a dataset.

@jonatandor35
I understand it’s a bit of a hassle, but it’s possible to work with the database.

@benibrodi It’s not only a hassle, it can also affect the performance a little bit-
If you use a dataset (for example, on a dynamic page), you’ll have to send another query to check the ID’s instead of getting them with dataset itself. It’s an additional back and forth.

@jonatandor35 Yes the perfomance derives from too many query calls. On a dynamic page I use that for a dataset and use the filter to get directly the “referenced items”. It’s much more faster then Query it.

But anyway, have a look at my Projekt with Multi-Query calls. Because when you open the Filter (click the Button “Filtre”), you see all the Checkboxes and that are all “Multi-Item References” to one Collection. And while you clicking the Checkboxes everytime its fire a Query and so fahr it works smooth. I hope that stays so when there are over 100 Objects. :smiley:
The Page: https://noe342.wixsite.com/website/kopie-von-activites

J.D.,you´re right, an array of _id´s is what you would expect. Now, I don´t use multi-ref´s, since they are not supported by other db´s (if I ever wanted to port). You state:
" the query just doesn’t retrieve this reference field at all "
Any idea what is DOES retrieve? Have you tried to JSON.stringify the object returned? It´s usually very revealing.

It doesn’t retrieve this field at all.

@benibrodi You’re right, you still can have a good performance with this extra query. But if we could avoid it, it’d be great. We need to save every fraction of second (because all these short delays pile up together).