Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

Databases Mongo Basics Working With Collections Querying Collections

Jesse Bartola
Jesse Bartola
10,438 Points

Huston Says the Same Thing Twice at 2:03

Maybe they forgot to edit one of those recordings out of the video?

3 Answers

Steven Parker
Steven Parker
231,236 Points

Yup, in the Querying Collections video, the phrase is repeated with only minor differences like exchanging the words "with" and "you want" for "and" and "you're going". I'd guess that the first phrase was supposed to be removed in editing.

What's really funny is that all this is faithfully recorded in the captions file:

2:04  Now in order to query by the title field, you simply supply the title field
2:09  as a key in query object with the value you want to query for.
2:13  Now in order to query by the title field.
2:16  You simply supply the title field as a key in the query object and
2:20  the value you're going to query for.

Good catch, Jesse. You should submit this to support and get your "special Exterminator badge".

the or operator expressed as the query operator $or

db.posts.find({$or [{ title: "blah blah"}, { title: "blah blah"}]}, { body : False, description : False}) you will find blah without the body and description because those are

Projector objects of boolean values.

is it possible to use the $or operator for something other than two similar queries indexes. For example title you can search for name "john" in the bothe title field and body field

db.posts.findOne({ $or [{ body: "john"}, {description: "john"}]}) ? What is difference between findOne and find?

https://docs.mongodb.org/v3.0/reference/operator/update/ here are a list of update operators $inc $mul $rename renames a field $setOnInsert If the update creates the insert, then this sets the value. Does nothing to actual document updates or update operations

$set sets the value of the field $unset removes a field from a doc

$min only updates the field if the value is less than existing field &max updates the field if value more than existing field

$currentDate Sets the value of field to be the date.

here are Query and Projection operators https://docs.mongodb.org/v3.0/reference/operator/query/

for instance $or, $and, $not, $nor $or is all documents that match either $and all documents that match both $not inverts query expression and returns documents that do not match query expression.? $nor returns all docs that that fail both clauses

for instance

$eq matches values that are equal to a specified value so { <field>: { $eq: <value> } } so: db.posts.find({tags: $eq: 3}) would retrun all tags with len of three? ?