Magic sql`` operator array
hey guys.
how can I pass a array fo strings to magic sql operator?
9 Replies
Depends on how are you planning to use it
I am going to check if a column value is in this array. I just want to pass it safely because the array comes from url search params
Use
inArray
You only need to check that length in > 0
inArray
will do that parsing for youThe column I am trying to to check is JSONB tough
@Angelelz I can’t use inArray because the column value is JSONB. I don’t know how to exactly use with JSONB columns
Oh hey, yeah
So, you have a jsonb column, and now you want to see if that jsonb exists in an array?
Or do you have a value, and you're trying to see if it's present in a jsonb column that is an array?
first of all, thanks for the reply,
I have a JSONB column with the following structure:
{ "value": "Completed" }
and I get array of values from url search params and pass it to a function where I do the database query using drizzle orm
["Completed", "In Progress", "Cancelled"]
.
I want to check the value
field of JSONB column exists in this array of values for filtering purposes.Try this:
Thanks a lot, I'll try it.
One more thing, which is completely unrelated to this:
I haven't been able to find information on how to make a unique constraint deferrable in the documentation.
I don't have experience with this concept. I don't think drizzle supports it.
Editing migrations would be the way to go, I would think