Skip to main content

Posts

Showing posts with the label MongoDB joins left outer joins

5 Best Ways to Rename MongoDB Collection [Rename]

“ How can I Rename a collection in MongoDB ?” Definition : “Rename or changes the name of an existing collection”. Try the Video live example of the code shown in this page using Robomongo ! Syntax:- { renameCollection: "Original_collection_name>" , to: "<New_collection_name>" , dropTarget: < true | false >} What is “ renameCollection ”? It is the name of the original collection to rename. What is “ to ”? It is the new name of the collection. What is “ dropTarget ”? If dropTarget is “true”, mongod will drop the target of renameCollection before to renaming the collection. The default value is “false”. Examples :- db.Original_Coll_Name.renameCollection( 'new_Coll_Name' ); // The “ db.collection.renameCollection() ” is not supported on sharded collections. // OR db.Original_Coll_Name.renameCollection( 'ifAlreadyExistColl' , true ); > show dbs admin 0 . 000 GB demoDB 0 . 0...

3 Best Ways to DROP MongoDB Database [DROP]

“ How to DROP Database in MongoDB ”? “ How many types to DROP Database ”? In this section, I am going to describes “ DROP” or Delete MongoDB Database. Below version 3.4, does not provide any user interface like SQL Server or “Robomongo” but MongoDB 3.4 solve this problem with help of “ Robomongo Management Tool” . As per my understanding, it is a great achievement of MongoDB to provide us Robomongo Management Tool. You can download Robomongo MongoDB interface and install MongoDB & Robomongo in your machine and start to Create, Rename and DROP MongoDB database, collections, functions and Users. 3 Ways to “DROP” MongoDB Database:- 1.       “Use” of Robomongo Management Tool. 2.       “Use” Command Line. 3.       “Use” ASP.Net C# Code. Here you can decide to DROP MongoDb database, collections and users. “DROP” MongoDB Database Using Robomongo Tool:- You should go (download U...

The Left Outer Join in MongoDB [$lookup Join]

“How to Join  query in MongoDB”? “How do I perform the SQL Join equivalent in MongoDB”? The  $lookup  is introduced in the  MongoDB  version 3.2  and it’s perform a “ Left Outer Join”  in the same database collection. The “ $lookup” stage does an equality match between a fields. The “ $lookup ” stage adds a new array field whose elements are the matching from the “ joined ” collection. The “ $lookup ” is an alternate way to implement Joins in MongoDB. Syntax: { $lookup: { from : “collection - to - join ”, localField: “Input - field - documents”, foreignField: “Input - field - from - documents - of - the - "from" - collection”, as : “Output - field - Array > } } Perform Joins using $lookup A collection Users contains { "_id" : 1001 , "name" : "Anil Singh" , "Age" : 32 , "Qualification" : "MCA...