#whereJsonContains usage

1 messages · Page 1 of 1 (latest)

leaden path
#

I have a user_data column on the options table with this record [{‘x’:’111’},{‘y’:’5555’}], how can I retrieve options where y = 5555 with the whereJsonContains

tropic summit
#

With whereJsonContains('user_data->y', '5555') 😉

leaden path
#

The syntax you give is not working. It output an empty array

tropic summit
#

I assume that this column has type json, right?

leaden path
#

Yes I try it before posting the question

#

Note that in the json you get x as a key in one object and y as a key on the other object

#

Your syntax work in the case where you have something like this [{‘x’:’3333´}, {‘x’:’4444’}]

tropic summit
#

Ok, i tested it and it seems that for json array content it should be like this whereJsonContains('user_data', ['y' => '5555'])