Skip to main content

Posts

Showing posts with the label Are mongodb ids unique ?

MongoDB CRUD Operation in ASP MVC.Net

Table of Content :- 1.       MongoDB Setup and Installations 2.       Add a User Registration Page and Save Records in MongoDB 3.       Get User Records from MongoDB through LINQ 4.       Edit/Update Records in MongoDB 5.       Delete/Drop Records from MongoDB through LINQ MongoDB Setup and Installations :- 1.       Download MongoDB using below link, http://www.mongodb.org/downloads?_ga=1.20290616.1294468948.1419862328 2.       Setup MongoDB as per below link instructions, http://docs.mongodb.org/manual/tutorial/install-mongodb-on-windows/ Stayed Informed – YouTube Video link for Setup MongoDB Stayed Informed - Why use MongoDB in MVC .Net? The main Reason is to Use MongoDB with ASP.Net MVC are, 1.       So Faster Development. 2.    ...

Why use MongoDB in MVC.Net?

“The MongoDB is now most popular cross platform NoSQL open source database management system. The MongoDB is written using the C++ language and developed by 10gen but now it's called MongoDB Inc .” Stayed Informed - 117 Recommend MongoDB Tutorial for Beginners Now, coming back to the point, “Why use MongoDB in MVC?”. The main reason is to use MongoDB with ASP.Net MVC are, 1.       It is so Faster Development. 2.       It is so Minimal Migrations. 3.       It is much Easier Collaborations. 4.       It is so Maintainable Design. 5.       It is much Rich Behaviours. 6.       Scalability. 7.       GridFS Example Source code for MongoDb with MVC 5 as, using System ; using System.Web.Mvc ; using MongoDB.Driver ; using MongoDB.Bson ; namespace MongoDemoApp.Controllers { ...

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 Create MongoDB Database [CREATE]

“How to Create Database in MongoDB”? “How many types to Create Database”? “How”, “When” and “Types to create database”? In this section, I am going to describes Create Database in MongoDB. 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. [ Video URL ] - CREATE Database MongoDB Using “ Robomongo Tool ”! You can Download Robomongo Management Tool and install MongoDB & Robomongo in your machine and start to create MongoDB database, create MongoDB collections, create MongoDB functions and create MongoDB users. 3 Ways to Create MongoDB Database:- 1.       “Use” of Robomongo Management Tool. 2.       “Use” Command Line. 3.       “Use” ASP.Net C# Code. Here you ca...

MongoDB Export with $mongoexport

In the MongoDB, $mongoexport is used to take the backups of db tables (collections) in JSON, CSV and TSV format using the command. This command should be executed in the command prompt not in MongoDB clients. MongoDB Export command options:   - h < mongo - host - name >                     --This command is not required!   - u < user - name >                                   --This command is not required!   - p < password >                                    --This command is not required!   - d < db - name >                   ...

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...

MongoDB ifNull Array - Aggregation

$ifNull  (aggregation) $ifNull is used to evaluate an expression and returns value. If the expression evaluates to a null value that time it returns to replacement expression value. Syntax :   { $ifNull : [ “expression”, “replacement-expression-if-value-is-null”] } For example , db.customers.aggregate([{        $project: {CustID: 1001,        CustomerCode: { $ifNull : [ "$CustomerCode ", " Pending Approval " ] } }  } ]); In the above example, if customer code is null that time the expression returns to “ Pending Approval ” (as per you). For more https://docs.mongodb.com/manual/reference/operator/aggregation/ifNull/ Thank you!