This gives clients flexibility to render these fields, without knowing the schema at all. Once we deploy Hasura GraphQL Engine on this database, a GraphQL query and it’s response looks like this with some sample data: Example query after adding some sample data The JSONB column spec is resolved as the underlying JSON object. For more insight into hstore, JSON and JSONB columns, and notes on when to use them, checkout this blog post from Citus Data. Both will make sure only a valid JSON can be inserted here, but with JSONB columns, we can query based on the JSON keys. The spec column can either be JSON or JSONB . Here is the schema for product table on Postgres: Let’s take a look at how we can use JSONB to model this product table and make some queries through Hasura GraphQL Engine. It is nearly impossible to create columns (schema) to capture all possible spec-fields for all kinds of products out there.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |