Reputation: 3975
The snippet below is taken from the Mongoose docs. My question is why put votes and favs under "meta". Why not have them on the same level as author, body, comments etc?
Is there any advantage to doing it like below? Is there any disadvantages?
var blogSchema = new Schema({
title: String,
author: String,
body: String,
comments: [{ body: String, date: Date }],
date: { type: Date, default: Date.now },
hidden: Boolean,
meta: {
votes: Number,
favs: Number
}
});
Upvotes: 0
Views: 26
Reputation: 64923
It's just a design decision. This is the shortest answer possible.
I would say that they've put votes and favs in an associated objects because they're some kind of stats and, if you think about "stats", in object-oriented programming, "stats" or "meta" must be an object.
Upvotes: 1