0

I'm new to hasura and i'm searching how to relate a table with a column of int of array to another table.

Let's say Users table is: enter image description here

..and Products table is: enter image description here

I want to return

products { id

name

number of users

}

MrCorn
  • 13
  • 4

1 Answers1

1

Looks like you need a user_products table. Hasura is meant to track relations in a relational database. Your schema is not the way a many-to-many relationship is accomplished. Have a look at Hasura's docs for a clear explanation although this is more of a general relational database concept than strictly a Hasura thing.

If you absolutely must use this schema, you can make a View and track it in Hasura. In your View, you can UNNEST product_ids (which will make a unique row for each id,product_id pair) and make the correct many-to-many relationships which you can then aggregate in hasura. This is not at all advisable.

Abraham Labkovsky
  • 1,771
  • 6
  • 12