wixData query filter not working...??

I have the following code to retrieve the total number of items in a database that match the “program” field value of either “Coed Spring 2021” or “Coed Spring & Summer 2021”… It is retrieving items that match these parameters but it is only getting 3 items. There are actually 67 items in the database and 45 of them have those matching values.

Here is the code I’m using:

// Mark registration full if over 48 members.
        wixData.query("soccerMembersDatabase")
        .hasSome("program", ["Coed Spring 2021","Coed Spring & Summer 2021"])
        .limit(100)
 /*.count()*/
        .find()
        .then( (results) => {
 let coedSpringCount = results.length;
                console.log("Coed Spring Members:",coedSpringCount);
                console.log(results.items);
 if (coedSpringCount >= 48) {
                    $w("#coedSpringCheckbox").disable();
                    $w("#coedSpringLine").show();
                    $w("#coedSpringFullMsg").show();
                } else {
                    $w("#coedSpringCheckbox").enable();
                    $w("#coedSpringLine").hide();
                    $w("#coedSpringFullMsg").hide();
                }
            } )
        .catch( (error) => {
 let errorMsg = error.message;
 let code = error.code;
        } );

I can’t see what the issue would be in this case. Would appreciate any ideas/help!

**I have also tried .totalCount instead of .length and both have the same result.

  1. Maybe you use the preview mode and expect to see the live results (you won’t, you’ll only see the sandbox collection), or maybe the opposite. You use the live site and expect to get the sandbox data (wrong).

  2. The queries are case-sensitive. Make sure everything is spelled exactly as in the query.

@jonatandor35 Thank you for the pointers. I have already checked both though and performed a sync from live to sandbox beforehand so all of the items are available in preview. Also ran a check on the live site and got the same results.

It’s odd that it’s getting 3 items, when all of the corresponding tags are spelled the exact same because they are automatically created via code. So there couldn’t be a random 3 that happen to be spelt differently - I also logged the items themselves to the console just to check if this was the case but the 3 are definitely spelt the same.

@lisamthorpe I see you used results . length instead of results . items . length

@jonatandor35 I also tried that, as well as .totalCount haha - same issue