Postgres function to show sum of user's credits

Desired state: We can query a graphql field userTotalCredits with an user ID, and get back a total sum of user's credits.

  • get familiar with the "user" and "user_item_credit" tables in ark_data_model.dbml and ark_data_model.sql
  • write a plpgsql postgres function that takes user_id as a parameter, does something like SELECT SUM(nb_credit) FROM user_item_credit WHERE user_id = 1 (but user_id is taken from the function parameter).

Useful documents:

Edited by Dave