- In mongoDB the data’s are displayed using the find().
- Selects documents in a collection and returns a cursor to the selected documents.
db.collection.find(query, projection)
Parameters |
Type |
Description |
query |
document |
- Optional.
Specifies selection filter using query operators. To return all documents in a collection, omit this parameter or pass an empty document ({}).
|
projection |
document |
- Optional.
Specifies the fields to return in the documents that match the query filter.To return all fields in the matching documents, omit this parameter. For details, see Projection.
|
db.wikitechy4.find()
{ "_id" : ObjectId("5731e045daa4a0bc932a2ff8"), "name" : "data" }
{ "_id" : ObjectId("5731e258daa4a0bc932a2ff9"),
"websitename" : "www.wikitechy.com",
"details" : "learn mongodb basics and step by step",
"author" : "venkat"
}
{ "_id" : ObjectId("5731e296daa4a0bc932a2ffa"),
"websitename" : "www.wikitechy.com",
"details" : "learn mongodb basics and step by step",
"author”: "venkat"
}
{ "_id" : ObjectId("5731e2eadaa4a0bc932a2ffb"),
"websitename" : "www.wikitechy.com",
"details" : "next row inserted",
"articlecount" : "40",
"author" : "jln"
}
{ "_id" : ObjectId("5731e56ddaa4a0bc932a2ffc"),
"websitename" : "www.wikitechy.com",
"rowdetails" : "last row updated",
"author" : "arun",
"comments" : [ {
"user" : "john",
"message" : "article is good",
"place" : "new york"
} ]
}
>
- Here in this statement, we display the data’s from the collection “wikitechy4” using the find() rich query.