System info
- Strapi Version: 3.2.5
- Operating System: Win10
- Database: Strapi Default (Postgre in production)
- Node Version: 14.8.0
- NPM Version: 8.1.0
- Yarn Version:
Hi all, before anything, I want to say thank you for everything you are doing with Strapi, I love this community.
Now… in short, I am building a custom backend for an app with collectible cards.
Each card is a piece of content that a user can obtain/collect and do certain actions with it.
For now, I have:
User (user-permissions default)
Card (content-type) → has all details about the card (name, title, content, image, etc…) there is a total of 200 cards in the entire app.
And I want to create many-to-many relationship and keep user-specific data about each card. For example,
User-card details: (User id:1, and Card id:1) → (is_new: true, is_favorite: false, progress: 8, level: 4, is_complete: false, etc…)
My question is, what would be the best way to do this, and out of these 3 approaches I tried, what would be the best and why?
*in my specific use case: I don’t need to change these user_card details from the admin panel, I just need to create/update them as easily as I can and as performant as possible from the custom controllers logic.
Also, Ideally when the user creates an account 1st time, I would like him/her to already have 20 of these card details as default: 20 cards are open for all users as part of the tutorial, and the rest of 180 the user would collect over the course of the journey. (is_collected: true, progress: 0, etc…) for each card.
Here are 3 ways I tried and I am not sure which one is the best solution for a use-case like this.
-
Adding attribute “collection_json” type JSON under User (content-type)
-
Adding reusable component “Collections” under User (content-type).
-
Creating new Content-type “User-Cards” which has relation with Card and User.
Currently, the 1st - JSON variant works with a lot of custom backend code logic, however, I am not sure if it may cause some other problems, like difficulty in querying for all cards a user has and the details for example… On the other side, a publish system for relationship of this type looks weird, although I can probably disable it… I just need someone to help me with the decision.
Also, I would use the same solution for other similar relationships like User - Objective / User - Item / User - Daily Quest…
Thanks a lot for any feedback in advance!