When I try:
export function myCollection_beforeQuery(query, context) {
let newQuery = query.include("referenceFieldKey");
return newQuery ;
}
I get an error. Is it impossible to add .include() in this hook?
When I try:
export function myCollection_beforeQuery(query, context) {
let newQuery = query.include("referenceFieldKey");
return newQuery ;
}
I get an error. Is it impossible to add .include() in this hook?
Are you using multiple refs as that is limited to the 50 only, after that you get the partialIncludes return.
You will have to look at using queryReference then.
https://www.wix.com/corvid/reference/wix-data.html#queryReferenced
It throws an error even if it’s a single reference field.
Can you try to substitute it for another query method just to see if it works with that instead?
If that not works either, then something else is causing it.
However, there is nothing to say that it shouldn’t work with a particular hook, I’m sure that if there was that it would already be mentioned in Wix docs somewhere.
Other methods work.
Only .include() doesn’t work, It throws "Cannot read property ‘push’ of undefined ".
@jonatandor35
Interesting to know why undefined returned then.
@yisrael-wix might be able to shed some light on this if he’s not still busy with cleaning desks…
Although note the api ref ‘If the returned value is of the wrong type, the value is ignored.’
Not going to be simple with just having the wrong value type setup so nothing is returned?