When doing the migration lesson I came across the statement that usinga projection saves data coming across the wire.
In my time spent I discovered that the statement is true when nothing is being found and returning 0. Otherwise if the search is bring back a truthy for each request the amount is realtively the same. If i search for dates and everything is a date it takes a long time. If I search for string and nothing is a string then the query comes back immediately.
I guess if the migration in this case has already been completed then it will save on an alert stating as such. but otherwise I am not seeing the benefit.
Also, could it be written differently or otherwise to save on the query in either condition?
here is the code sample.
// a projection is not required, but may help reduce the amount of data sent
// over the wire!
const predicate = { lastupdated: { $exists: true, $type: "string" } }
const projection = { lastupdated: 1, _id: 0}
const cursor = await mflix
.collection("movies")
.find(predicate, projection)
.toArray()