Database Schema

We will be using two tables for our app. You can create these tables from the Hasura console.

Users

The users table will contain two fields

  • auth0_id: text primary key unique
  • name: text

Todos

The todos table will contain the following fields

  • id: text primary key unique
  • userId: text
  • text: text
  • isCompleted: boolean
  • deleted: boolean; default: false
  • createdAt: timestamp with timezone, default: now()
  • updatedAt: timestamp with time zone, default: now()

Permissions

A user is able to create, select, update and delete only todos that belong to them. This can be enforced by setting permissions as shown below:

Permissions

Did you find this page helpful?
Start with GraphQL on Hasura for Free
  • ArrowBuild apps and APIs 10x faster
  • ArrowBuilt-in authorization and caching
  • Arrow8x more performant than hand-rolled APIs
Promo
footer illustration
Brand logo
© 2024 Hasura Inc. All rights reserved
Github
Titter
Discord
Facebook
Instagram
Youtube
Linkedin