[MongoDB]: For loop to generate documents with array, sub and nested documents
Find below sample for loop to generate a document with array, sub-document, nested-document use mydb db.studentscol.drop() for(var i = 1; i <= 1000 ; i++){var r= Math.random().toString(36).substring(7); db.studentscol.insert( { _id:i, name:r, address: { address_id:i, state:r,country:”India”,street:{name:r,colony:{ name:r,pin:r}}}, hobbies: [{h1:r},{h2:r},{h3:r},{h4:r}] });} //…