Search text in JSONField

Viewed 444

I use peewee with SQLite. One of my models contains the JSONField (docs link) and now I need to query all rows where this field contains my string.

class Market(Model):
    ...
    data = JSONField()
    class Meta:
        database = db

If I try the following code, nothing returns:

Market.select().where(Market.data.contains(search))

Example data:

  • Market.data: ['123', '456', '789']
  • search: 456

How to find all rows where Market.data field contains the search text?

1 Answers
Related