wixData.query ignoring status of draft

I’ve got this query:

wixData.query("datasource")
        .hasSome("product", prodId)
        .eq("Status","Draft")
        .find()
        .then(async (results) => {
          return results;
        });

It works fine for items with a status of “Published” but anything with a status of “Draft” is ignored.

I added
.eq(“Status”,“Draft”)

to try and force it:

wixData.query("datasource")
        .hasSome("product", prodId)
        .eq("Status","Draft")
        .find()
        .then(async (results) => {
          return results;
        });

but it makes no difference.

How can I include “Draft” status items in my results?

@mab1138 It’s difficult for any of us to help you on this since we can’t see the “datasource” collection. The only thing that comes to mind is that you might be assuming too much with the hasSome function. Is it possible that the prodId that you’re feeding it returns no records that have the “Draft” status?

Hey Anthony, Thanks for the response…

The ProdId is valid:

  • If I run the query as is it returns no results. If I change the status from “Draft” to “Published” and run the same query it works as expected.

So, the “hasSome” works, but it appears the " . eq ( “Status” , “Draft” )" function doesn’t work.

@mab1138 It is case sensitive, so if values of the Status field in the collection are in there as “draft” and not “Draft”, that would be an explanation for why it’s not returning anything.

That would be, but doesn’t seem to be the problem either. I exported the collection as CSV and viewed the file in text editor to verify…

Hi mab,

Could it be that instead of using “Status” you have to use a lower case “status”.
Field keys in a collection always change the first letter to a lowercase.
Go to the collection → look for the column → click on it → click properties → look for the field key.

Kind regards,
Kristof.