I have the following script (script.js):
categoricalVars = db.frekvencija_ctg.find().toArray();
db.ctg.find().forEach(e => {
db.emb_ctg.insert({ ...e, frekvencija: categoricalVars });
});
When I try to load it in Mongo shell via load("script.js"), I get the following error:
[js] SyntaxError: illegal character :
If I run these expressions in Mongo shell one by one with copy/paste, they work and I get desired result. What is wrong in script?