MongoDb Architecture for Level Of Seperation
<p>What will be the ideal architecture for maintaining degree of separation between users in MongoDb?
For example I have a collection "users" with the following 3 documents(This architecture can be wrong. I expect a correct architecture in answer please):</p>

<pre><code>{
    _id: ObjectID('abc'),
    name: 'abc',
    friends: ['def', 'xyz']
},
{
    _id: ObjectID('def'),
    name: 'def',
    friends: ['ghi', 'xyz']
},
{
    _id: ObjectID('ghi'),
    name: 'ghi',
    friends: ['jkl', 'xyz']
}
</code></pre>

<p>I want to query the path of separation between users. So please help me out with a right architecture for the same or a right mongodb query.</p>

<pre><code>abc-&gt;is friend of-&gt;def-&gt;is friend of-&gt;ghi
</code></pre>