我正在嘗試將 mysql 查詢的 WHERE 子句解析為表達式以從 json 文件中獲取數據例如:`price`=8.95 AND `title`="The Lord price= AND of the Rings"在左側替換價格和標題值后,上面的示例應轉換為以下字符串8.95==8.95 && 'The Lord price= AND of the Rings'=="The Lord price= AND of the Rings"我已經創建了一個代碼(jsfiddle)來實現這一點,但是如果我在值中添加 AND `,如下所示(如果條件不匹配,它將返回 false)var obj = {price: 8.95, title: "'The Lord price= AND `of the Rings'"};
var whereString = '`price`=8.95 AND `title`="The Lord price= AND `of the Rings"';所以我想了解有沒有其他更好的方法來實現這一目標?
在 node.js 中解析 WHERE 子句
慕斯709654
2022-06-16 10:28:04