How to display number of items in database collection

Hi, i have created a collection of all students registered on my website. I want to now show on my homepage, how many students have registered, as a dynamic value. Can you help me write the code for doing this? thank you,

-Where should be showed the wanted dynamic value?
-When should be shown the wanted dynamic value?

In a text/input-field when page loads?

How to get the value?
Where to get the value?

When a user has fullfilled his registration, the user will be added into 2x-different places…

  1. Contacts (wix-CRM)
  2. PMD (PrivateMembersData)

How to get the value?

You will need to work on backend to get your wished value, paying atttention to the suppress-options.

Take a look onto wix-crm-backend or onto wix-users-backend API-DOCS.

You can use the query’s count() function to query the Members/PrivateMembersData database collection:

wixData.query("Members/PrivateMembersData")
   .count()
   .then( (num) => {
      let numberOfItems = num;
   } )
   .catch( (error) => {
      let errorMsg = error.message;
      let code = error.code;
   } );