MongoDB provides methods for ref and populate, and supports SQL operations like join. This article gives a practical example:
1. Data 1:
var New Schema ({    User: {        type:string    },    title: {        type:string    },    tag: [{        type: String    }],    content: {        type:string    },    count: {        type:number,        ' default ': 0     }});
2. Data 2:
var New Schema ({    name: {        type:string    }, Time    : {        type:date    },    conments: [{        // Only collection's _id        ' Daob '    }) can be used in the Id,mongo of the DAOB saved here;
3. Insert operation:
varb =NewDaobmodel ({User:' Fredric ', Title:' Title1 ', tag: [' Tag1 ', ' tag2 ', ' tag3 '], content:' Nothing to say, just test ',    }); B.save (function(err) {varA =NewDaoamodel ({name:' Sinny ', Time:NewDate (), conments: [b._id]}); A.save (function(err) {returncallback (ERR); })    });
4. Find operations:
MONGO does not support true join operations, so the requirements in this example can only be split into two steps
//You can use aggregations to implement more complex queries.    Daobmodel.find ({        ' tag ': {            $in: [' Tag1 ']        }    }, {        1      function(err, IDS) {        daoamodel.find ({            conments: {                $ in: IDS            }        ). Populate (' conments '). EXEC (function(err, Docs) {            return  Callback (err, docs);        }     );
MongoDB implementation Join