How to abstract mysql dynamic parameter queries (no, one, multiple parameters)?

problem description

on the basis of the general query connection.query (querySql,values,function () {}) of the mysql module in NODE.JS, how to abstract the mysql dynamic parameter query (no, one, multiple parameters)?

related codes

has unconditional parameters selectAll ()
has query ("SELECT * FROM TABLE", null,callback);
has a conditional parameter select (values)
expected and final result: "SELECT * FROM TABLE"

there is query ("SELECT * FROM TABLE WHERE?", values,callback);
where general values= {age: 23};
expected and final result: "SELECT * FROM TABLE WHERE age=23"

preliminary attempt

integrate unconditional parameters into one conditional parameter
query ("SELECT * FROM TABLE WHERE?, values,callback);
where general values= {1: 1};

the expected result is

"SELECT * FROM TABLE WHERE 1: 1;

but the error message will be reported. The error message actually seen

Error: ER_BAD_FIELD_ERROR: Unknown column"1" in "where clause"
it queried the first 1 as a column and reported an error.

< H1 > initial attempt failed < / H1 >

other attempts

does multiple conditional parameters look like this? Select (values)
query ("SELECT * FROM TABLE WHERE?", values,callback);
if there is values= {age: 23 age gender: "male"};

the expected result is

"SELECT * FROM TABLE WHERE age=23 and gender:" male";

but the error message will be reported. The error message actually seen

check the manual that corresponds to your MySQL server version for the right syntax to use near" gender = "male"" at line 1;

in addition, my attempt

if values= [{age: 23}, {gender: "male"}];
outputs the same result as values= {age: 23}. The method ignores the second conditional parameter.

(this parameter form values= [{age: 23}, {gender: "male"}];
in query (" UPDATE TABLE SET? WHERE?", values,callback); is available)

< H1 > try and fail < / H1 >

other attempts

query ("SELECT * FROM TABLE WHERE? AND?", values,callback);
values= [{age: 23}, {gender: "male"}];
this is successful, but it all looks silly, because they are all query statements, nothing more than the number of parameters, is there a better way to integrate them

Mar.29,2021
MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1b3a8b4-345ec.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1b3a8b4-345ec.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?