MERN freemuim schema setup

Viewed 24

I am building a MERN stack application where I want to set a freemium based model for users containing 3 tiers, namely - bronze(free), silver(cost x), gold(cost y). The users are supposed to be charged monthly.

How do I set the MongoDB schema for the same?

PS: I can easily set a very basic key-value pair but I just want to get opinions if there is a standardized method to do it that can be flexible if I decide to change cost of silver and gold tiers.

1 Answers
db.users.aggregate([
  {
    "$lookup": {
      "from": "tiers",
      "localField": "tier",
      "foreignField": "_id",
      "as": "tiers"
    }
  }
])

mongoplayground

Related