Question about Showing/ Hiding a container

I have just started learning js roughly a month, month and a half ago. I am not the greatest but I learn fast.

I am trying to show, or uncollapse a container box only if a certain field from my database contains data.
What would be my best way to go about this. Nothing special about the field, just a text field. The container box has text in it, but nothing special.

My biggest issue is pulling the data from the database, I thought I had a solid understanding and I do not.

I should make it clear that I am trying to collapse this container if a REFERENCE field is empty.

A sample would be great, obviously I would like to learn how to do it, not just copy and pasta.

Thank you,
Jared

Hi Jared!

Have you looked at the isNotEmpty function in Wix Data Query?
https://www.wix.com/corvid/reference/wix-data.WixDataQuery.html#isNotEmpty

You can query your collection (also using include(). [and include the reference field] for example).
The if the retrieved object doesn’t contain this field, hide()/show() the element.
https://www.wix.com/corvid/reference/wix-data.WixDataQuery.html#include

Fields that are empty usually have falsy values. So you can set an if statement to exclude the value if it is either undefined or ‘’.
https://www.wix.com/corvid/forum/community-discussion/how-can-i-check-if-a-dataset-field-is-empty

Thank you! I actually figured out what I needed too! I was over complicating how to do what I needed to do. But I will read up on all those links you gave me, in case I need them for future reference. I appreciate your time!