Sunday, 4 June 2017

Mongodb Schemas for different types of Posts/Articles

I'm developing an application with Mongodb, Mongoose and Expressjs in which there are articles or posts of different types. For example there's URL post which only includes of a URL or address and doesn't have text inside of it. There's normal posts, Map posts, Image posts and bunch of other types.

Now I want to define the schema of Posts in my Application. I'm a bit confused if I should be defining different schemas for each of these since they should have different attributes and properties when they share some properties or, put all possible properties inside the Post schema and use an attribute with the name of type to specify the type of the post that's been shared.

What's the best practice to do such thing?



via mamsoudi

No comments:

Post a Comment