db.createCollection("Students");

db.Students.insert([{rollno:1,name:"Shivam",age:19,branch:"comp",address:{city:"pune",state:"mh"},hobbies:["badminton","books"]},
                    {rollno:2,name:"Kavita",age:19,branch:"entc",address:{city:"banglore",state:"karnataka"},hobbies:["tennis","books","cooking"]},
                    {rollno:3,name:"Shreya",age:13,branch:"entc",address:{city:"pune",state:"mh"},hobbies:["badminton","tennis"]},
                    {rollno:4,name:"Sneha",age:21,branch:"mech",address:{city:"nasik",state:"mh"},hobbies:["basketball","books"]},
                    {rollno:5,name:"Neha",age:10,branch:"civil",address:{city:"nasik",state:"mh"},hobbies:["cooking","books","drawing"]},
                    {rollno:6,name:"Riya",age:21,branch:"entc",address:{city:"mumbai",state:"mh"},hobbies:["badminton","dancing"]},
                    {rollno:7,name:"Sumit",age:12,branch:"civil",address:{city:"nagpur",state:"mh"},hobbies:["singing","cooking","dancing"]},
                    {rollno:8,name:"Richa",age:19,branch:"comp",address:{city:"mumbai",state:"mh"},hobbies:["badminton","books","cooking","dancing"]},
                    {rollno:9,name:"Atharv",age:21,branch:"mech",address:{city:"banglore",state:"karnataka"},hobbies:["badminton","dancing"]},
                    {rollno:10,name:"Nishant",age:19,branch:"entc",address:{city:"pune",state:"mh"},hobbies:["tennis","dancing"]}]);
 
// all students information   
// db.Students.find();

// student information whose age is greater than 15 
// db.Students.find({age:{$gt:15}});

// student information sorted on name field
// db.Students.aggregate({$sort:{name:1}});

// update student branch computer of rollno 3
// db.Students.update({rollno:3},{$set:{branch:"comp"}});
// db.Students.find();

// remove document with rollno 1
// db.Students.remove({rollno:1});
// db.Students.find({});

// student information whose name starts with A
// db.Students.find({name: {$regex : /^A/i}});

// student information whose name ends with a
// db.Students.find({name:{$regex: /a$/i}});

// total number of documents available in collection
// db.Students.count();

// display first 5 documents
// db.Students.find().limit(5);

// display all documents instead of first 3
// db.Students.find().skip(3);

// display name of students who live in pune city
// db.Students.find({"address.city":"pune"},{name:1,_id:0});

// display list of different cities from where students are coming
// db.Students.distinct("address.city");

// display list of different cities with number of students from belonging to that city
// db.Students.aggregate([{$group:{_id:"$address.city", no_of_students:{$sum:1}}}]);

// display only name of all Students
// db.Students.find({},{"name":1,_id:0});

// display the hobbies of each collection
// db.Students.find({},{"name":1,"hobbies":1,_id:0})

// drop collection
db.Students.drop()









Embed on website

To embed this program on your website, copy the following code and paste it into your website's HTML: