New Discussion

Notifications

You’re not receiving notifications from this thread.

How to use LIKE to query a jsonb field

0
Rails

Hi guys, am really stuck with this, I have a jonb field called occurrences, and one of my records has this on it :

[{"occurs_on"=>"2019-02-04 23:00:00 UTC", "status"=>"none"}, 
{"occurs_on"=>"2019-02-05 23:00:00 UTC", "status"=>"none"}]

am trying do a query that check if there is any record with the date 2019-02-04

I tried this :

Event.where("events.occurrences ->> :key LIKE :value", 
:key => 'occurs_on', :value => '2019-02-04%')

But not working for me, any idea?

Join the discussion
Create an account Log in

Learning Ruby on Rails? Join our newsletter.

We won't send you spam. Unsubscribe at any time.