Subscription Event

I need to be able to send my database a true or false update based on a user subscription being active or canceled. I have been able to connect to my database on my VPS from wix using a NPM package but I can not figure out how to isolate the purchase and cancel of a subscription in an event to trigger the update to my database.

Key Variables:

user_email= //site user
sub_active = //true false

Any help would be appreciated.