I have a Json data stored in my MongoDB database as showing below,
{
"_id" : ObjectId("5f17109a9013adc57942af2a"),
"name" : "Demo Name",
"dob" : "04/01/2000",
"phone" : "1234567890",
"email" : "[email protected]",
"password" : "0987",
"cPass" : "0987",
"location" : "Civil line, Mumbai"
}
And I only want an name (sub document) i.e Demo Name here from this whole document:
: Demo Name
I'm writing this query:
var employ = await coll.findOne( { "email": "[email protected]" } );
But it gives me whole document in var employ. I only want name in var employ. How can I do that with Mongo Dart.
This query finds the element whose email value is matched with "[email protected]" and after finding element, It is going to exclude the fields i.e _id, dob, phone, email, password, cPass and location. The value remains is "Demo Name" along with it's key.
For removing key we have to use the following code.