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

Single record is different indeed as it returns the record object directly. So not a array list first.

2 Likes

Yeah. This will only work for single query.
For multiple records an empty array will always evaluate to true in a JS environment(browser and server) while for PHP an empty array will evaluate to false.

Mistery solved. Sorry @Mozzi I missed you were talking about a multiple result query.

1 Like

Dont have to say sorry… the main thing is I learned something new… and the end goal is to have a NodeJS application …

Ok… so how would one then handle a FILE UPLOAD CONDITION…
as this also works in php but it ignores it in Node…

To check “condition” that the upload is not 0? Guess not with .count() > 0;

I have tried > 0…
But even if the file field is empty it still removed the file on the server…
I dont want to try a million things as that gets met into trouble… so ill just ask :wink:

how-would-one-handle-a-file-upload-condition-i-have-tried-bigger-than-0

What are you trying to check If the file upload step uploaded a file? Or if the user selected a file in the file input?
Also please try to keep separate questions in separate topics.

Hi Teodor. I want to check that the user did not upload a file. If he uploads a file… then process the removal… if the client did not upload anything… but still pressed submit / update… then it wont remove the files online. Thank you. DO you want me to remove this and place it in its own question?

I should have posted the complete screenshot

If the user did upload something… then … it removes the old file and replaces it…
If no file selected… then it skips… the rest

and yes… i know i repeat myself a 100 times…
thank you for the help again

So which of the two you want to check actually?

  • check if the upload step uploaded a file

Or

  • check if the user selected a file in the file upload input in the form when submitting the form
    ?

Well you tell me please what the best solution will be?

i know i sound like a broken record… but this is how i have done this … with php for the last 3 years with the tutorials given only. SO im open to both solutions and answers as then i can learn.

So maybe in this instance its better then to check the file selected… ? i dont know… please advise what you would think would work the best.

Well that is why I am asking what exactly do you want to check…
If you want to check if the file is selected in the input then use the post var as a condition.
If you want to check if a file is uploaded by the upload step then check the file upload > name returned by the file upload step.

1 Like

100% im getting a better idea now to how these conditions work… thanks Teodor…