How to get a record count

I’m confused as to how to determine the number of records within a recordset using a query.

manually added ‘.count()’ to code but get 1 when there are any number of records.

image

Checked out a really old tutorial by George but couldn’t find ‘Collections>count’ option in data format menu, this is what I see…

Is your query a single record one by any chance? I’ve just checked and Collections appears for me when adding a query to the page.

The screenshot above suggests a multi query

When you view in a browser, what do you get in Dev tools under Network for the SC call? Have you made any changes to the API file that haven’t been saved?

Hi sitestreet, no not a single record…

1 Like

Very importantly, what IS the entire query?

The simplest is ex:
SELECT COUNT(*)
FROM product;

If COUNT() isn’t available in the list then make a Custom SQL query. I assume you don’t query multiple tables, just the singular table in your database.

If you need to find a count of all records with a particular value, and not include the count of records that don’t have that value, then something like

SELECT COUNT(DISTINCT SupplierID)
FROM product;

Hi NewMedia great that works…

just don’t understand why, when I try and replicate Georges tutorial I’m not getting the same options in the format menu…using 3.9.9 by the way :slight_smile:

Wappler has been changing fast. All versions contain upgrades/improvements.

1 Like

You are probably using an older Wappler version. This (not seeing collections menu) has been fixed in some of the previous Wappler 4 beta versions.

2 Likes

Just out of interest, I would like to start working on my project with Wappler 4, how would I safely do that without the possibility of corrupting my project created in 3.9.9.

Would I just copy my project file as a backup and open in 4? I’m not sure how docker works so I am very cautious about introducing any potential issues.

Would you say Beta 13 is safe enough to start developing existing projects or should I wait?

I’ve been using v4 Betas through every release and if I spot an issue (they’re beta after all) then I quit completely and open v3.9.9. Switching between the two should be fine but just make sure you don’t have both running at the same time.

Just so I’m clear you work on the same project switching from v4 and v3, you don’t have a copy of the project. Editing a seperate copy for each version?

Yep, I have a single project and open it in both versions. But I never have both running at the same time.

I’m not using NodeJS or Docker, though, so I can’t speak for that scenario.

1 Like

Well all you need to do is to open your project in Wappler 4, no need to do anything special.
The latest beta is full featured and stable, last version before the official release.

2 Likes

Thankyou sitestreet, I have experienced so many problems in the past with the database connections and docker I am really nervous about switching to and from the beta and 3.9.9…thanks again cant wait to get stuck into the beta properly :slight_smile: