1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | module Repos.Subscriptions ( create , update ) where import Database.SQLite.Simple.QQ (sql) import Repos.Utils import Data.Text create :: (CanDB m) => Text -> Text -> Text -> m DbR create sId userId customerId = do execute [sql| insert into subscriptions(id, user_id, stripe_customer_id, active, created_at) values (?, ?, ?, ?, datetime()) |] (sId, userId, customerId, True) update :: (CanDB m) => Bool -> Text -> m DbR update active customerId = do execute [sql| update subscriptions set active = (?) where stripe_customer_id = (?) |] (active, customerId) |