I have a business collection.
The businesses are reviewed by users.
Each user can only review a business once. Future reviews will simply replace the former one.
This is how we store it:
"Reviews" : {
"gusyanto" : {
"day" : "December 21, 2012, 8:08 am",
"review" : "Tes review"
},
"sapi" : {
"day" : "December 21, 2012, 8:18 am",
"review" : "makanan ini sangat enak"
}
}
Alternatively we can also use this:
"Reviews" : [{
"userid" : "gusyanto",
"day" : "December 21, 2012, 8:08 am",
"review" : "Tes review"
},
{
"userid" : "sapi",
"day" : "December 21, 2012, 8:18 am",
"review" : "makanan ini sangat enak"}
]
}
So basically we want can store it as a dictionary where the key is the userid
or we can store it as an array where userid
is the field key. So the key in the second approach is static, namely userid
.
We want to index the entries. For example, a user may want to know what businesses he has reviewed.
Which approach I should use?