Database Reference
In-Depth Information
Extreme Scoping, 300 pages
Note that the 1 in the sort command indicates ascending order and -1 indicates descending
order.
If we wanted to count the number of documents returned in this same find( ) query, we can
execute this statement:
db.book.find( { pageCount : { $gt : 275 } } ).count( )
This statement would return 2 for the two records returned.
EXERCISE 3: INTERPRETING QUERIES
Based on the sample dataset below from the Title collection, what would each of the fol-
lowing two queries return? See Appendix A for the answer.
Title Name
Page Count
Publication Year
Author
Amazon Review
Extreme Scoping
300
2013
Larissa Moss
4.5
Data Engineering
100
2013
Brian Shive
4.25
Business unIntelligence
442
2013
Barry Devlin, PhD
5
Data Modeling Made Simple
250
2009
Steve Hoberman
4.35
db.title.find( { $or : [ { pageCount : { $gt : 200 } },
{ publicationYear : { $lt : 2010 } } ] } )
db.title.find( { authorName : { $ne : “Shive” } } )
U PDATING D ATA IN M ONGO DB
The update( ) function modifies one or more documents from a collection. The general
structure for a update( ) statement is:
Search WWH ::




Custom Search