
- MongoDB Tutorial
- MongoDB - Home
- MongoDB - Overview
- MongoDB - Advantages
- MongoDB - Environment
- MongoDB - Data Modeling
- MongoDB - Create Database
- MongoDB - Drop Database
- MongoDB - Create Collection
- MongoDB - Drop Collection
- MongoDB - Data Types
- MongoDB - Insert Document
- MongoDB - Query Document
- MongoDB - Update Document
- MongoDB - Delete Document
- MongoDB - Projection
- MongoDB - Limiting Records
- MongoDB - Sorting Records
- MongoDB - Indexing
- MongoDB - Aggregation
- MongoDB - Replication
- MongoDB - Sharding
- MongoDB - Create Backup
- MongoDB - Deployment
- MongoDB - Java
- MongoDB - PHP
- Advanced MongoDB
- MongoDB - Relationships
- MongoDB - Database References
- MongoDB - Covered Queries
- MongoDB - Analyzing Queries
- MongoDB - Atomic Operations
- MongoDB - Advanced Indexing
- MongoDB - Indexing Limitations
- MongoDB - ObjectId
- MongoDB - Map Reduce
- MongoDB - Text Search
- MongoDB - Regular Expression
- Working with Rockmongo
- MongoDB - GridFS
- MongoDB - Capped Collections
- Auto-Increment Sequence
- MongoDB Useful Resources
- MongoDB - Questions and Answers
- MongoDB - Quick Guide
- MongoDB - Useful Resources
- MongoDB - Discussion
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 Articles
- How to delete documents from a collection in MongoDB?
- How to retrieve documents from a collection in MongoDB?
- Get the maximum mark records from a collection with documents 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 query
- Fetching all documents from MongoDB Collection in a beautified form
- Find value above a specific value in MongoDB documents?
- How to delete all the documents from a collection in MongoDB?
- How to find MongoDB documents in a collection with a filter on multiple combined fields?
- Find all duplicate documents in a MongoDB collection by a key field?
- Get MongoDB documents with max attribute per group in a collection?
- Get all embedded documents with “isMarried” status in a MongoDB collection
- Display only a single field from all the documents in a MongoDB collection
- How can I search a collection to find a nested value in one of its documents in MongoDB?
- Retrieving specific documents from collection by _id in MongoDB

Advertisements