0

I'm creating an application where you can get some FREE CONTENT and the rest of the content is PAID and requires a subscription to access.

I'm going to use Braintree as a payment provider to handle subscriptions. The way braintree works is: You setup a 'subscription plan' in the dashboard & that plan is given a unique planId.

I have thought of a very simple way of modelling my subscription model in Mongo, here it is:

**Collection: Article**
_id: uuid
title: string
description: string
requiresBraintreeSubscription: ["XX"]

**Collection: User**
_id: uuid
name
activeSubscriptions: [ { startDate, endDate, planId } ]

The question I have is: Is it fine to reference the planId (planId directly from Braintree) directly into my document fields OR should I create a seperate collection that stores current active subscriptions AND LINK that subscription collection _id in the requiresBraintreeSubscription and activeSubscriptions fields?

I thought of this solution to prevent the need on setting up another collection called 'subscriptions' and also to prevent the need of doing joins all the time to check if a user is subscribed to a specific plan.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.