I'm just starting using MongoDB and more used to relational DBs. I want to store users (id, name ...) in one collection and posts (id, title, content, userID) in another. At the frontend, I want to show the posts including the user, who posted them. Obviously the username and not a cryptic id. In a relation DB, I would join the tables and sent the combined object to the frontend.
But what would be the best approach for a Mongo DB? Should I include the username in the posts collection or also join the collections? I'm really unsure about the joins in Mongo since I heard it should be avoided.
Thanks for any help or suggestions!
question from:
https://stackoverflow.com/questions/66067464/best-practice-monogdb-embed-or-not 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…