Prac 4 Get link Facebook X Pinterest Email Other Apps October 13, 2025 4B)mongodump --d (database name) --c (collection name) --o (path)4C)mongorestore --d (database name) --c (collection name) --o (path) Get link Facebook X Pinterest Email Other Apps Comments
Prac 5 October 13, 2025 5Apackage com.example.MongoDB; import com.mongodb.client.MongoClient; import com.mongodb.client.MongoClients; import com.mongodb.client.MongoDatabase; public class MongoConnection { public static MongoDatabase connect() { String uri="mongodb://localhost:27017"; MongoClient mongoClient=MongoClients.create(uri); return mongoClient.getDatabase("dbs1"); } } 5B) package com.example.MongoDB; import org.bson.Document; import com.mongodb.client.MongoCollection; import com.mongodb.client.MongoDatabase; public class Mongo_Insert { public static void main(String[] args) { MongoDatabase database MongoConnection.connect(); MongoCollection<Document> collection=database.getCollection("Employee"); Document doc=new Document("Name", "Jyoti") .append("Age", 27).append("EmailId", "jyoti07@gmail.com"); collection.insertone(doc); System.out.println("Document inserted successfully!"); } 5C) package com.example.Mo... Read more
Prac 1 October 13, 2025 1A)use Krish drop.database() 1B)show dbs use Krish db.createcollection("emp") db.createcollection("emp1") show collections db.emp.drop() show collections 1C)use Krish db.createcollection("emp") db.emp.insertMany([{"Name":"Krish","Age":20,"email_id":"krish123@gmail.com"},{"Name":"Trish","Age":21,"email_id":"trish123@gmail.com"},{"Name":"Hrish","Age":22,"email_id":"hrish123@gmail.com"},{"Name":"Vrish","Age":23,"email_id":"vrish123@gmail.com"}]) db.emp.find() db.emp.updateOne({Name:"Krish"},{$set:{Age:24}) db.emp.deleteOne({Name:"Trish"}) Or use Krish db.createCollection("emp") db.emp.insertMany([ { "Name": "Krish", "Age": 20, "email_id": "krish123@gmail.com" }, { "Name... Read more
Comments
Post a Comment