Ch3 Lab - $group and Accumulators

Without giving away too much about the answer :thinking:, at some point in my pipeline I want to convert a substring I parsed from the documents into an integer. But in the Mongo shell I get the following error:
[js] Error: command failed: {
“operationTime” : Timestamp(1561670380, 3),
“ok” : 0,
“errmsg” : “Unrecognized expression ‘$toInt’”,
“code” : 168,
“codeName” : “InvalidPipelineOperator”,
“$clusterTime” : {
“clusterTime” : Timestamp(1561670380, 3),
“signature” : {
“hash” : BinData(0,“rjZDFNvbMZylcMG9HvAo6mlomgg=”),
“keyId” : NumberLong(“6661714504839069697”)
} : aggregate failed :

I have tried replacing $toInt with a call to $convert and get a similar error. What could be causing this?

I found the answer to my own question. $toInt and $convert exist for mongo 4.0 and higher, but the server is running 3.6 still. I simply removed the part of the expression that converted types, and the aggregation ran successfully.



Good work, glad you found it.