0

I want to search through a table for a particular string. I can find the row when the tag matches the contents exactly. But I want to find all occurrences of "red" even when the tags column has multiple colors in a string like "blue, green, purple, red". Is it possible to use SQL to query? I found a vague reference involving chaining but it wasn't clear how to make it work in this case.

Here's what I have for the exact match...

app.post("/admin/search", function(req, res) { var data = req.body; req.models.images.find({tags:data.tags}, function(err, results) { res.send(results); //Returns on perfect match }); } 

1 Answer 1

0

This seems to work.

 app.post("/admin/search", function(req, res) { var data = req.body; req.models.images.find().where("tags LIKE ?",["%"+data.tags+"%"]).run(function(err,results){ res.send(results); }); }); 
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.