[SOLVED] Get and post total from DB

I have a survey that allows users to choose which classes they’d be interested in being offered (Boolean). What I’d like to do is to be able to post next to each option the number of times others have chosen that particular class.

I have set up voting before, but what was regards to me presenting the info for them to click on in a dynamic page. This is info based on user submissions on a multistage form.

Pretty much need to get total count of values from a column, disregarding null fields.

UPDATE

I am playing around with this code:

   wixData.query('NewYearSurvey') 
        .eq('spin', 'Spin Class') 
        .count() 
        .then((num) => { 

let spinCount = num;
})

But am unsure of how to now get $w('#text34).text = spinCount

let sets local variable. You set spinCount to a local variable and can not be called outside of the brackets from .then
define spinCount Before calling the query

let spinCount 
wixData.query('NewYearSurvey')
.eq('spin','Spin Class')
.count()
.then((num)=>{
spinCount = num
})

let will only let the variable be read within the function it was defined
Hope this helps

Hey Ethan!

You are right! Total brain fart and overlooked that. I have now defined the count in the function.

But I am having another fart sigh I have text on my page #text34 that I would like to be the value of spinCount, but can’t get my brainwaves to connect the dots. A little frustrating only bc I feel like this is something simple and have done it before, but now not sure.

Would it be better to use an input instead of text element to show this value?

$w('#text34').text = String(spinCount)

Thanks Ethan!