LOC Payments

Storage

environment

table_name

location

test

test-loc-service

us-west-2

prod

prod-loc-service

us-east-2

Keys

  • PK - USER#<user_id>

  • SK - LOAN#<loan_id>#PAYMENT#<payment_id>

  • GSI1PK - USER#<user_id>

  • GSI1SK - STATUS#<payment_status>#LOAN#<loan_id>#DUEDATE#<due_date>#PAYMENT#<payment_id>

  • GSI2PK - PAYMENT

  • GSI2SK - STATUS#<payment_status>#DUEDATE#<due_date>#PAYMENT#<payment_id>

Query Patterns

Query Index Conditions

Get payment by loan and payment ID

Primary

PK = USER#user_id, SK = LOAN#<loan_id>#PAYMENT#payment_id

List payments for a given loan

Primary

PK = USER#user_id, SK begins with LOAN#<loan_id>#PAYMENT

List all payments for a given loan in a given status

GSI1

GSI1PK = USER#user_id, GSI1SK begins with STATUS#<payment_status>#LOAN#<loan_id>

List all payments for a given user in a given status

GSI1

GSI1PK = USER#user_id, GSI1SK begins with STATUS#<payment_status>#LOAN

List all payments in scheduled status due date x days in the future, used for upcoming notifications

GSI2

GSI2PK = PAYMENT, GSI2SK begins with STATUS#scheduled#DUEDATE#<date_x_days_in_future>#PAYMENT#

List all payments in scheduled status with a due date of today

GSI2

GSI2PK = PAYMENT, GSI2SK begins with STATUS#scheduled#DUEDATE#<todays_date>#PAYMENT#

List all payments past due in scheduled status

GSI2

GSI2PK = PAYMENT, GSI2SK less than STATUS#scheduled#DUEDATE#<todays_date>