

- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
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
Find a value in lowercase from a MongoDB collection with documents
To find a value in lowercase, use the toLowerCase() method in MongoDB. Use the method in find() to find the value in lowercase.
Let us create a collection with documents −
> db.demo172.insertOne({"SubjectName":"MySQL"}); { "acknowledged" : true, "insertedId" : ObjectId("5e3838ce9e4f06af551997e1") } > db.demo172.insertOne({"SubjectName":"mongodb"}); { "acknowledged" : true, "insertedId" : ObjectId("5e3838d69e4f06af551997e2") } > db.demo172.insertOne({"SubjectName":"MongoDB"}); { "acknowledged" : true, "insertedId" : ObjectId("5e3838db9e4f06af551997e3") }
Display all documents from a collection with the help of find() method −
> db.demo172.find();
This will produce the following output −
{ "_id" : ObjectId("5e3838ce9e4f06af551997e1"), "SubjectName" : "MySQL" } { "_id" : ObjectId("5e3838d69e4f06af551997e2"), "SubjectName" : "mongodb" } { "_id" : ObjectId("5e3838db9e4f06af551997e3"), "SubjectName" : "MongoDB" }
Following is the query to find a value in lowercase −
> db.demo172.find({"SubjectName":"MONGODB".toLowerCase()});
This will produce the following output −
{ "_id" : ObjectId("5e3838d69e4f06af551997e2"), "SubjectName" : "mongodb" }
- Related Questions & Answers
- How to delete documents from a collection in MongoDB?
- How to retrieve documents from a collection in MongoDB?
- Evaluate one of more values from a MongoDB collection with documents
- Get the maximum mark records from a collection with documents in MongoDB
- Find value above a specific value in MongoDB documents?
- Fetching all documents from MongoDB Collection in a beautified form
- Get the maximum mark records from a collection with documents in MongoDB query
- Find all duplicate documents in a MongoDB collection by a key field?
- How to find MongoDB documents in a collection with a filter on multiple combined fields?
- How to delete all the documents from a collection in MongoDB?
- Display only a single field from all the documents in a MongoDB collection
- Get MongoDB documents with max attribute per group in a collection?
- Find documents with arrays not containing a document with a particular field value in MongoDB?
- How can I search a collection to find a nested value in one of its documents in MongoDB?
- How to find two random documents in a MongoDB collection of 6?
Advertisements