-
|
Hi dear all! Does Tortoise-ORM provide filtering by keys in JSONField? Consider: `class Item(Model): item = await Item.create(name='something', data = {'some_key': 'some_value'}) Can I filter something like bellow?: like Django does. |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 1 reply
-
|
Anyone update on this as this is not currently available. You can't query JSON field data in tortoise I suppose? |
Beta Was this translation helpful? Give feedback.
-
|
As for now, v0.25.1, you can filter by key value of the JSONField like this: items = await Item.filter(data__contains={"some_key": "some_value"}) |
Beta Was this translation helpful? Give feedback.
-
|
I found that it is possible to use
Firstly we have to register |
Beta Was this translation helpful? Give feedback.
I found that it is possible to use
filterlookup for Json fields.the snippet bellow
items = await Item.filter(data__filter={'some_key__in': ('value1', 'value2')})Firstly we have to register
inlookup to tortoise: