Chap 3 accumulator expressions lesson video " " symbols

at the 4:34 mark suddenly quote symbols are used around the calculated value
{$project: { _id:0,
“yearly_sales (millions)”: {sum:"

but the several preceding examples of calculated values for max, min, cpi - none of those are enclosed… is there any reason for this difference??

In actual fact, the use of quotes began from 1:14.

You seem to be very keen on quotation marks. As I can tell, you’ve done quite a few courses already and should be able to come up with your own conclusion on this?
So why is “$trends.icecream_cpi” and “yearly_sales (millions)” enclosed in quotes? What happens if you take away the quotes?

Hi @James_58604,

The following screenshot will give you a hint for enclosing yearly_sales (millions) field within the quotes:

Please let me know, if you still have any questions.


mmm… here is the student experience:
time 4:11
average_cpi: {$avg: …
cpi_deviation: {$stdDevPop: …

time 4:30
“yearly_sales (millions)”:{$sum:…

to the left of the : symbol is a string in all cases
and to the right is an aggregate calculation

I’m not saying the video is wrong and I realize that without the quotes in the latter case it throws an error…but I will say in the most general terms, while concepts are explained very well - the implementation syntax is rarely explained at all - - and code won’t run when a character is wrong…so the topic is a big deal when it comes down to making things work the first time.

…so IMO…explaining & pointing out changes/variations in syntax really would be helpful … I wish there was more of it…

When do you quote a field?

  1. When it contains a space or special characters
  2. When it contains a dot (.), for example when you’re accessing an array element or an embedded document
  3. When it doesn’t contain 1 or 2 but you feel like quoting

I would imagine that the recommended prerequisite course M001 MongoDB Basics, covers these basic conventions:

oh 001 probably did…but students going from course to course non stop are drinking from a fire hose here - - one appreciates some friendly repetitive reinforcement …

It’s probably a good idea to slow down and drink from a tap instead of a fire hose :smiley:
I understand your point, but this particular case isn’t necessarily MongoDB specific. Since you say you’re a SQL guy, just like T-SQL uses square brackets (i.e. [field name with spaces]), ANSI SQL uses quotes in a similar way that MongoDB does (i.e. “field name with spaces”). Command Line uses quotes in a similar fashion too, and many other programming languages follow suit. That’s probably why something this trivial wasn’t reinforced. However, I’m sure that @Sonali_Mamgain will take your feedback on board.

If it’s any encouragement, when I took these courses, I was enrolled in batches of 3 courses in a given session.

1 Like