Wixdata query record count code not working?

Question:
[Clearly ask your question.]

Product:
Using Wix Editor, Velo, Wixdata

My query accepts search criteria and runs perfectly connecting to a Repeater.

I assume I have a syntax problem with the totalCount statement. Watched multiple videos and read docs but can’t get this to work.
matchCount = results.totalCount

The code includes arbitrarily setting variable matchCount to 123, then using that variable in the above totalCount statement (expecting a value of 4 ) but it remains 123 as if the statement never ran.

Failing query counts code

Any suggestions are appreciated. Thanks, Mike
Below is the code

let matchCount = 123 ;
wixData.query(“Archives”)
.ge(“title”, searchFrom)
.and(wixData.query(“Archives”).le(“title”, searchTo))
.find()
.then(results => {
$w(‘#repeater1’).data = results.items
// let resultCount = results.totalCount
matchCount = results.totalCount
}) // ================= “then” statement END

// Check results
console.log ( "count is - " + matchCount)

I resolved the problem. It appears that the processing related to the query count actually ran before the query finished. I just included that processing within the “then” processing and it worked.
Thanks anyone who may have looked into this problem for me.

1 Like