query hasSome uses EUQAL instead of "contains"?

Hi,

I am trying to use the hasSome. According to the documentation:

The hasSome() function refines a WixDataQuery or WixDataFilter to only match items where the array value of the specified property contains any of the specified values.
When I try it it looks the haSome does EQUAL comparison and not CONTAINS. A record is selected only if one of the value in the hasSome fully EQUALS to a value in the collection and not contained in the collection.
For example:
if “colors” field of record #1 has the value of: “red,purple” and I do
let newQuery = query.hasSome(“colors”, “red”, “yellow”, “blue”);
then record #1 will not be selected.

however it will be selected if I do:
let newQuery = query.hasSome(“colors”, “red,purple”, “yellow”, “blue”);

Please advise.

Hi,

hasSome takes array values and checks if field equals any of these array items. So for example if you have a collection with values:

blue
light red
red
yellow
brown
black
light green

let newQuery = query.hasSome(“colors”, “red”, “green”);

it will return only red.

I am afraid you did not answer my question. You just put a simple example. My question is very simple: In the formal API documentation it says: " contains " and not " equals ". In reality it performs “equal”. Either fix the documentation or the functionality! I would ask that someone knowledgeable from Wix will answer this.

hi erezsh,
yes you are correct the hasSome filter use equality to evaluate the condition.
we’ll fix the docs.

Thank you. It would have been better to modify your implementation of hasSome, not the documentation as “contains” is more useful than “equal” (you can use “contain” to implement “equal” by selection of your data but not the other way around).