NodeJS - Condition Server Side not working. But in PHP it does. Same stucture

Windows 10
Local Dev - localhost3000
Using phpmyadmin for the databse
Wappler v4.4.5

Very reluctant to post in Bugs… but here go again…

I have simple insert into a database via a form. And it works well. Both in PHP and Node.
This is without adding the Condition… just a simple insert

Now i add a condition the the api to check the database … if the record is in the database… then it should just ignore the entry… if not in the database it should insert it… pretty simple.


I switched the debug on

Now if I run the script… it gives me a “notification” that is done… even if the entry is in the database… ( so it should not be but “success”

Now the problem comes in… if i remove the entry from the database and press insert it shows “done” but its not in the database at all… So once i add a condition to the insert… it just does not want to do its thing.

I have tested the exact same scenario in php, same form same api structure… and it works…

But now with the same structure on Node… it gets to a point… and then it says Query object object…
Same structures… same database… But the PHP is working for me and not the Node one …

I used just a “bare bone” structure to test this… and remains the same…
Once inside the conditional region … it processes up to a point and then stops…
Browser source code rendered…

You have the debug on in your query options - this will prevent it from executing.

I switched it on so that you can see what is doing… because if I do… switch the debug off… its not working… with the debug on… it work with php…

If anybody want to test…

DROP TABLE IF EXISTS favorites_list;
auction_id int(11) DEFAULT NULL,
user_id int(11) DEFAULT NULL,
item_id int(11) DEFAULT NULL,

– Dumping data for table favorites_list

INSERT INTO favorites_list (id, auction_id, user_id, item_id) VALUES
(208, 93, 9, 3577),
(206, 93, 9, 3575),
(207, 93, 9, 3576),
(224, 98, 9, 4075);

api and viewa attached… (1.5 KB) (2.6 KB)

As the same thing is working in php as im converting my site to node … if i run it in php it works… eg same conditions… but once with node… its not functioning. As i have duplicated the steps 100% …

but any advice would be appreciated… Am i not doing the condition right in node.? could it be that it will work in php but the same not working in node.? i dont know… i have tried this for the last 5 hours… and it just comes to the same thing…

Out of interest I notice you check your query and if its got a record you then do nothing (you just have a comment here)

I maybe wrong but have you tried this with more than just a comment in the THEN section I feel this could be the issue, what I would try is change the condition to query == null and then have your insert in the THEN section. Completely delete the ELSE by right clicking it.

Your screenshots from the UI show an old version. Are those screenshots recent?

This will always give success, because even if the entry is in the database, you're not returning an error.

You need to do something like this:

Notice the step "Response 401", I'm returning a "401 Unauthorized" error, and then handle like this:

dmx-on:success="browser1.goto('/account')" dmx-on:unauthorized="browser1.alert('Wrong login details')">

I'm unsure how to trigger a dmx-on:error. Maybe you can use Validator component instead of Response

Edit: Also use Database Single Query instead of Database Query

Here’s the response code mappings

1 Like

most recent 4.4.5 :slight_smile:

Hi Apple.

I have

dmx-on:success="notifies1.success('Done');" dmx-on:invalid="notifies1.success('Did not work');"

as said. i have the exact same thing is PHP and working like a charm… im doing some more tests this morning on Node… just to see why…

Ill give the single query also a go…

Ok… so have done some more testing… maybe the logic does not work the same as it does for PHP? But if so its very confusing… i have removed the INSERT completely… and just set some values… its been working like this for the last 3 years on a live php server so i know its working… my question would be … does Node then handle the “condition” with different logic?

@patrick @Teodor

Testing with php and node… without a condition set within the query.

PHP fine…

Node fine

But once i add the condition in the database query… builder… then its were it goes pair shaped for me using node…

PHP Fine…

Node not doing the THEN step

The i do a DEBUG.

PHP… seems to be fine and returning everything.

Node… i dont know if it should return anything… but normally when i see object Object i know im in trouble …

I hope this helps…

PS! So far Node is great… It just getting small things sorted out… its fast …
Pitty not all my clients have node hosting here … so php will be for most of them… but i agree… node is the way forward…

The DB Query conditions are handled in the same way across different frameworks. I just converted a project from .NET to NodeJS and no DB Query needed any change in the conditional groups to work in Node.

What data is expected to be returned when conditions are / aren't met?

Could it be because of the types? Strings and doubles… and so on?

trying to make a condition run …(then / else) if the condition is true or not… see above screenshots… database is the same … conditions is the same…

Try changing the conditional check to or check.auction_id

Turn this debug option off for the database query! It should not be ON. The only debug option you need on is the one in the server connect settings.

Then - what is the exact condition you are trying to check and what is your database query? Single, multiple records?

I think it could be… that the database is Int and the wappler picking it up as String

Using phpmyadmin because of all the databases in it… before node was a thing


I did turn the debug off… for testing… and if you look at the php and the node… it handles it differently…
then i only switched back on the debug to see if there was a difference on the output…

trying to make a condition run …(then / else) if the condition is true or not… see above screenshots… database is the same … conditions is the same…

And what is the condition you want to check then?
What is the query type?