Doing this query:
select * from menuitems
return new Promise((resolve, reject) => {
db.transaction((tx) => {
tx.executeSql(
"select * from menuitems",
[`%${query}$%`],
(_, { rows }) => {
useDevLogData(rows._array, "filterByQueryAndCategories rows._array");
}
);
}, reject);
});
I have this set of result:
[
{
"id": 1,
"uuid": "1.0",
"title": "Spinach Artichoke Dip",
"price": "10",
"category": "Appetizers"
},
{
"id": 2,
"uuid": "2.0",
"title": "Hummus",
"price": "10",
"category": "Appetizers"
},
...
]
But when i do it like this i have no result: returning empty []
return new Promise((resolve, reject) => {
db.transaction((tx) => {
tx.executeSql(
"select * from menuitems WHERE title LIKE ?",
[`%${query}$%`],
(_, { rows }) => {
useDevLogData(rows._array, "filterByQueryAndCategories rows._array");
}
);
}, reject);
});
Also I would need to combine this search text, e.g. %Spinach% query to filter category on an array of categories, e.g. ["Appetizers", "Salads"], How do I query to filter the category column based on array of string? and also based on that, I need to query the field title? I need to do something like:
"select * from menuitems where title LIKE %Spinach% AND category LIKE ["Appetizers", "Salads"]"