On Thu, Jul 9, 2009 at 4:16 PM, Vlad GURDIGA <[email protected]> wrote:
> I apologize for the fact that I may be a little off-topic but reading
> this article a question came up regarding the second model presented
> in the "One to Many: Embedded Documents" section:
>
> {
> "_id":"Scott",
> "type":"contact",
> "name":"My Friend Scott",
> "phones":[{"home":"(650) 555 - 2200"},{"mobile":"(650) 555 - 2201"}],
> }
>
> What is the pros and cons of having phones stored as an array of
> associative hashes versus having them as an associative hash? Here is
> what I mean:
>
> {
> "_id":"Scott",
> "type":"contact",
> "name":"My Friend Scott",
> "phones":{"home":"(650) 555 - 2200","mobile":"(650) 555 - 2201"}
> }
>
> It seams to me more intuitive syntax.
An array of associative hashes allows duplicate keys, that is
[{"home":"(650) 555 - 2200"},{"mobile":"(650) 555 - 2201"},{"mobile":"(123)
456- 000"}]. And more generally, the idea is that these are like child
documents of the master.
FB