Article Categories
- All Categories
-
Data Structure
-
Networking
-
RDBMS
-
Operating System
-
Java
-
MS Excel
-
iOS
-
HTML
-
CSS
-
Android
-
Python
-
C Programming
-
C++
-
C#
-
MongoDB
-
MySQL
-
Javascript
-
PHP
Selected Reading
Use result from MongoDB in shell script?
Let us first create a collection with a document −
>db.useResultDemo.insertOne({"StudentFirstName":"Robert"});
{
"acknowledged" : true,
"insertedId" : ObjectId("5cda70f5b50a6c6dd317adcd")
}
Display all documents from a collection with the help of find() method −
> db.useResultDemo.find();
Following is the output −
{ "_id" : ObjectId("5cda70f5b50a6c6dd317adcd"), "StudentFirstName" : "Robert" }
Here is the query to use result from MongoDB in shell script with var keyword −
> var studentName=db.useResultDemo.findOne({},{_id:0});
> studentName
Following is the output −
{ "StudentFirstName" : "Robert" } Advertisements
