- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
MongoDB query to store File Name and location?
To store, let us see an example and create a collection with documents −
> db.demo645.insertOne( ... { ... 'fileName' : 'MongoDB Program', ... 'fileLocation':'C:/users/workspace/AllMongoDBProgram/MongoDB Program' ... } ... ); { "acknowledged" : true, "insertedId" : ObjectId("5e9c78f36c954c74be91e6e8") } > > db.demo645.insertOne( ... { ... 'fileName' : 'SumOfTwoNumbers.java', ... 'fileLocation':'E:/eclipseWorkspace/AllJavaPrograms/SumOfTwoNumbers.java' ... } ... ); { "acknowledged" : true, "insertedId" : ObjectId("5e9c78f36c954c74be91e6e9") } > db.demo645.insertOne( ... { ... 'fileName' : 'Script.sql', ... 'fileLocation':'C:/MySQLQuery/Script.sql' ... } ... ); { "acknowledged" : true, "insertedId" : ObjectId("5e9c78f46c954c74be91e6ea") }
Display all documents from a collection with the help of find() method −
> db.demo645.find();
This will produce the following output −
{ "_id" : ObjectId("5e9c78f36c954c74be91e6e8"), "fileName" : "MongoDB Program", "fileLocation" : "C:/users/workspace/AllMongoDBProgram/MongoDB Program" } { "_id" : ObjectId("5e9c78f36c954c74be91e6e9"), "fileName" : "SumOfTwoNumbers.java", "fileLocation" : "E:/eclipseWorkspace/AllJavaPrograms/SumOfTwoNumbers.java" } { "_id" : ObjectId("5e9c78f46c954c74be91e6ea"), "fileName" : "Script.sql", "fileLocation" : "C:/MySQLQuery/Script.sql" }
- Related Articles
- How to store query output in temp MongoDB database?
- Downloading file to specified location with Selenium and python.
- How to select a directory and store the location using Tkinter in Python?
- How to create and store property file dynamically in Java?
- MongoDB Query to combine AND & OR?
- MongoDB query to fetch only the “Name” field based on roles?
- How to store array values in MongoDB?
- How to query a key having space in its name with MongoDB?
- MongoDB query to display documents with a specific name irrespective of case
- How to store list in a txt file and read list from txt file in android?
- MongoDB query to select distinct and count?
- Test Numpy array values for infiniteness and store the result in a new location
- Best way to store date/time in MongoDB?
- How to store MongoDB result in an array?
- How to download any file and save it to the desired location using Selenium Webdriver?

Advertisements