Ch 3 Lab 1 Parse string to int

I have parsed the “Won…” into a string field, but I can’t convert it to INT or DOUBLE in a pipeline step (I’m using Compass btw). So my field looks like this:
str_oscars:“3” in the GUI, but when I parse it using NumberInt() into a new field, i get num_oscars:NaN. I’ve tried $toInt and $convert and neither seem to work at all (“unrecognized expressions”).
Hopefully this is simple and tangential to the core problem, and TIA!

Edit: I realized, I do the calculations based on the rating, not the number of oscars, and it’s already a number, but i’d still like to know the answer to the original question :slight_smile:

From $toInt and $convert documentations at:

https://docs.mongodb.com/manual/reference/operator/aggregation/toInt/

Both are new in version 4.0. 8-(

1 Like

Ah, and I just found we’re on 3.6.8, thanks!

Hi,

Anyway, I would suggest to use a regular expression to match the awards field…

José Carlos

1 Like