Загрузка...

MongoDB All Operations

Aim : Installation of MongoDB and basic commands to deal with the following. Steps : Download and install MongoDB with default options.(https://fastdl.mongodb.org/win32/mongodb-win32-x86_64-2008plus-ssl-4.0.7-signed.msi) After download then go to the installation directory of MongoDB and run a file named "mongod" with administrator priveleges. Then run "Mongo.exe" I have already downloaded and installed.. 1) If you want to use a database with name mydb, then use DATABASE statement would be as follows − use mydb To check your currently selected database, use the command db db If you want to check your databases list, use the command show dbs. show dbs Your created database (mydb) is not present in list. To display database, you need to insert at least one document into it. db.movie.insert({"name":"Trojan AnuragK19"}) show dbs 3) Create collection in MongoDB. db.createCollection("mycollection") 4) Inserting into collection. db.mycollection.insert([{'name':'Anurag Kurmi','age':21}]) Multiple values insertion var cs=[{'name':'Anuj Kurmi','age':18},{'name':'Rahul Kumar','age':25},{'name':'John Nadar','age':30}] db.mycollection.insert(cs) 5) MongoDB Query Document db.mycollection.find() db.mycollection.find().pretty() ....(json format) 6) MongoDB update document db.mycollection.update({'name':'Rahul Kumar'},{$set:{'name':'Amit Patel'}}) db.mycollection.find() 7) Delete Document in MongoDB db.mycollection.remove({'name':'Amit Patel'}) db.mycollection.find() 8) limit() and skip() method in MongoDB. db.mycollection.find({},{"name":1,_id:0}).limit(1) 9) Sorting of documents in MongoDB. db.mycollection.find({},{"age":1,_id:0}).sort({"age":-1}) 10) MongoDB Indexing. db.mycollection.ensureIndex({"name":1}) 11) MongoDB projection. db.mycollection.find({},{"name":1,_id:0}) db.mycollection.find({},{"name":1,_id:0}).limit(1).skip(1) 12) Dropping a collection in MongoDB. db.mycollection.drop() 2) Dropping a database in MongoDB. db.dropDatabase() Thats it for this video thanks for watching document subscribe and comment...

Видео MongoDB All Operations автора Базы данных: Управление транзакциями
Страницу в закладки Мои закладки
Все заметки Новая заметка Страницу в заметки