read Flashcards

1
Q
db.runCommand(
   {
     find: "restaurants",
     filter: { rating: { $gte: 9 }, cuisine: "italian" },
     projection: { name: 1, rating: 1, address: 1 },
     sort: { name: 1 },
     limit: 5
   }
)
A

find within the restaurants collection, field name of rating with a value >= 9 AND cuisine with a value of italian.

projejction with return only the fields: name, rating, and address.

Sort with sort it by name

there will be a limit of 5 articles

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q
db.runCommand(
   {
     find: "restaurants",
     filter: { rating: { $lt: 5 } },
     readConcern: { level: "majority" }
   }
)

what’s readConcern?

A

The following operation on a replica set specifies a read concern of “majority” to read the most recent copy of the data confirmed as having been written to a majority of the nodes.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

What’s collation?

A

Collation allows users to specify language-specific rules for string comparison, such as rules for lettercase and accent marks.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

findAndModify

A

The findAndModify command modifies and returns a single document. By default, the returned document does not include the modifications made on the update. To return the document with the modifications made on the update, use the new option.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

upsert with findAndModify?

A

when true, findAndModify() will either:

  • create a new document if no documents match the query
  • updates a single document that matches the query
How well did you know this?
1
Not at all
2
3
4
5
Perfectly