 
  Data Structure Data Structure
 Networking Networking
 RDBMS RDBMS
 Operating System Operating System
 Java Java
 MS Excel MS Excel
 iOS iOS
 HTML HTML
 CSS CSS
 Android Android
 Python Python
 C Programming C Programming
 C++ C++
 C# C#
 MongoDB MongoDB
 MySQL MySQL
 Javascript Javascript
 PHP PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Fetch records in MongoDB on querying its subset
You can use $all operator. Let us first create a collection with documents −
> db.subsetOfAnArrayDemo.insertOne({"StudentProgrammingSkills":    ["Java","MongoDB","MySQL","C++","Data Structure","Algorithm","Python","Oracle","SQL Server"]}); {    "acknowledged" : true,    "insertedId" : ObjectId("5cb9d1e1895c4fd159f80804") } Following is the query to display all documents from the collection with the help of find() method −
> db.subsetOfAnArrayDemo.find().pretty();
This will produce the following output −
{    "_id" : ObjectId("5cb9d1e1895c4fd159f80804"),    "StudentProgrammingSkills" : [       "Java",       "MongoDB",       "MySQL",       "C++",       "Data Structure",       "Algorithm",       "Python",       "Oracle",       "SQL Server"    ] } Following is the query to get the subset of an array −
> db.subsetOfAnArrayDemo.find({ StudentProgrammingSkills:    { $all: [ 'MongoDB', 'MySQL' ] } } ).pretty(); This will produce the following output −
{    "_id" : ObjectId("5cb9d1e1895c4fd159f80804"),    "StudentProgrammingSkills" : [       "Java",       "MongoDB",       "MySQL",       "C++",       "Data Structure",       "Algorithm",       "Python",       "Oracle",       "SQL Server"    ] }Advertisements
 