Multiple criteria for data query

I have looked and looked for syntax to be able to create an “and” condition when making a Wix data query. Thank you to Jeff (Wix) from a post in 2017 that I never found before today.
https://www.wix.com/velo/forum/tips-tutorials-examples/you-can-chain-two-or-more-of-the-same-query-functions

The quick answer is adding the .hasSome(“[field name]”,“[value]”) to the query. For example:

wixData . query ( “Announcements” )

        . eq ( "hidden" ,  **false** ) 
        //filter on what's in "page" field (this acts like "and" in the find) 
        . hasSome ( "page" ,  "main" ) 
        . find () 

Here’s more documentation on “.hasSome”
https://www.wix.com/velo/reference/wix-data/wixdatafilter/hassome

This made my day!

Comments were closed on Jeff’s post so I added this one in case it is helpful for someone else.

1 Like