Articles → MONGODB → Projections In MongodbProjections In MongodbIn this article, we will discuss projections in MongoDB.Purpose Projections in MongoDB enable you to precisely select only the data you need from a document, rather than retrieving the entire document.Example While querying a document using the find method, we specify the flag as 0 (zero) for those fields we do not want to fetch.Consider the following table: -Click to EnlargeOur requirement is to fetch only the subject field, not the _id field. So, we will use the following query: -db.Articles.find({}, {subject:1, _id:0})Output Click to EnlargePosted By - Karan Gupta Posted On - Friday, March 17, 2023 Query/Feedback Your Email Id Subject Query/Feedback Characters remaining 250
db.Articles.find({}, {subject:1, _id:0})
Query/Feedback