I’m trying to use a tagify element to find all entries in the database where a field contains any of the tagify input tags, but can’t figure out how to do it.
The query is Field_name in {{$_GET.tags}} The get parameter is populated by the tagify element. But it will only work with one tag, when a second tag is added it no longer returns any result.
What I’m hoping to achieve is to find “all users where the user’s field contains any of the tagify tags”
e.g.
Field is “favourite_colour” and User A has “red”, and User B has “blue”.
Another user searches for users with favourite colours of either red or blue in the favourite field.
I want it to return both users.
Perhaps someone has already used tagify in this manner and can point me in the right direction?
Thank you @bpj, unfortunately that does not solve the issue. The behaviour is the same, it will only return a result for the first tag.
It will find everyone whose field says “blue” and when “red” is added as a second tag, it finds no results at all. I thought maybe it’s not looking at individual fields, but for a comma separated field with “blue, red” so I tried creating a field for one user that says “blue, red” but it didn’t find that either.
Running in the browser; http://localhost:3000/api/talent/test?skills=pink
Returns
Running in the browser; http://localhost:3000/api/talent/test?skills=blue
Returns
Running in the browser; http://localhost:3000/api/talent/test?skills=pink,blue
Returns (nothing)
I’ve tried every possible combination of things that I can think of. like splitting the string in the query. setting the param to an array. converting text to string and then splitting string… I’m just throwing stuff at it at this point to see if anything works.
Using “in” as opposed to “contains” returns a 500 status, no idea what to make of that.
As a text field with the values comma separated as such “pink,green,blue”. I’ve also tried it as a string field, but I understand nodeJS doesn’t care if it’s text or string type?
Being an old Bubbler, you had to define a field to be a “list” for this type of operation. But I wasn’t able to find a way of defining the field type as a list equivalent. e.g. an array type.
And the behaviour seems to be that it doesn’t understand it’s individual values, but a, you know, text. and finds the single word “blue” and “pink,blue” as a word of course doesn’t exist, so it won’t find anything.
That’s why I also tried the separate operation “,” in the query builder.
That is a bad practice. You should not store values like that.
You need a table for your users and another table for the colors, related by the userid.
The other option is to use a json field type to store the values in the database, as explained here: Inserting Tagify Values into a Database
Right, so I tried that as well. that was the original issue of the thread. I had the same result, which lead me to believe that perhaps it had to be a comma separated field
So here’s the original example set up. not a subtable of skills, since I couldn’t figure out how to search a sub table, that will be an upcoming thread
how on earth… it works!! I was so sure I had tried that combination, especially after @bpj suggested split.
Time to backtrack and figure out what I did wrong before.
Thank you so much @Teodor this was doing my head in for the better part of yesterday.