Please help because I am facing problem with usage Server Side javascript (I am aware that it was deprecated in version 8).
But as I undrestand correctly the String.normalize static function support was removed but the prototype form should still work.
Maybe it is problem with my javascript knowledge but when I am trying to execute below function:
const getUnicodeNormalizeName = function (developer){
return developer.normalize(“NFC”);
}
In aggregate pipeline:
const options = { ordered: true };
const developersTeam = [
{ t_id: “t1”, developer : “Mike”},
];
await arraysCollection.insertMany(developersTeam, options);
const expectedTeams = [JSON.stringify({t_id: “t1”, name: “Mike”})];
// WHEN
var result = await arraysCollection.aggregate([{
$addFields: {
name: {
$function: {
body: getUnicodeNormalizeName.toString(),
args: ["$developer"],
lang: "js"
}
}
}
}
]).toArray();
Then I get such exception:
MongoServerError: PlanExecutor error during aggregation :: caused by :: TypeError: developer.normalize is not a function :
Full code is on github: