1

I have a custom table that consists of 2 columns, id and data. I want to create a view table with filter. The table columns should be id, product, and item. product and item are from the data column which contains JSON data (for example {"product": "a", "item": "b"}).

Is it possible to create this type of view?

As per my knowledge, it's not possible to create because a view works with columns that exist in the database table.

2
  • Which module are you using for JSON field support? Sep 27, 2021 at 9:25
  • @PatrickKenny No, I'm not using any module for the JSON field. it's a custom table with the Datatype of JSON.
    – Lokesh1024
    Sep 28, 2021 at 4:32

1 Answer 1

1

JSONB is Postgres only but Drupal can create JSON field storage types for MySQL too. There are modules that can do both. However, Views support will be light until the additional query functions for JSON are supported. But, you can write the queries yourself in code and it will work.

As for getting Views to query custom tables, this is possible if you describe your data to Views using its API hook(s).

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.