![]() Here we discuss the Introduction, Mongo DB-like query by using find () function examples with code implementation respectively. The output is a cursor referencing the filtered document records. We can specify the string, regex, or regular expression for matching the values in the parameters of the find() function. We can implement the functionality of the like query in Mongo DB by using the find() function in the format â db.collection.find(). We can also change the name of the field specified in the above example as a city to whichever field as per requirement. The output of the execution of the above query statement will be as shown below retrieving the count as 1 because there is only one hill station located in Pune city as per the inserted sample database.Īs shown in the above query statement we can make the changes in the string mentioned between the two forward slashes to specify a different string to be matched each time. Let us firstly create a sample database shown below: Note: If you want to have an access to the result set returned by the find() function with a driver then, in that case, you will have to use for that particular driver language, a cursor handling mechanism to handle the result set. The query parameter is used for filtering the selection of the records to be scanned by the find() function. The default value of the projection parameter when not specified retrieves all the fields of the document. Projection is used for specifying the fields to be retrieved for matching records.
0 Comments
Leave a Reply. |