How to filter by Array in Vapor 4?

Viewed 247

I can do a filter in Vapor 4 like this

Category.query(on: req.db)
   .filter(\.$description ~~ searchTags)

description here is a String. And it will match description to any of the strings in the searchTags array.

But what if description was also an array? Is there a way to match all the values in descriptionArray to the searchTags array?

1 Answers

If description was an array, then it should be made into an array of child objects, this way you can search for using a simple filter on description and parent id.

Related