MongoDB can be used as a file system, taking advantage of load balancing and data replication features over multiple machines for storing files.
In this article we will learn how to find
documents in MongoDB with a practical example
Previous articles have provided an
introduction to MongoDB and the set up and installation, and few command line
options.You can get them from the following:
The objective of the article is to learn how to use the find
command to retrieve documents from Mongo database.
Will take a look at Query criteria, field selection, and cursor
previous article we have seen the options of querying using different operators.
In this part 2 we will see few more…
animal document contains a tag field and the tags field contains an array of
So let us
see how to match among those…
notice that we are finding the tag field of tag which matches cute
is strictly quality and it also case sensitive
find animals who are cute or in the ocean we will get some animals which are
cute and some which are in ocean but not necessarily both of them as shown
Now if we
want to insist that there would be both ocean and cute tagged we can issue the
following command by using all operator as shown below…
want to find the document which are none in the tags we can use nin operator as
In this article we have seen the different ways of finding documents..In coming articles we can see how to use cursor operations