mongoose-shortid
mongoose-shortid copied to clipboard
Missing "let" in index.js when using strict mode
Hi,
I'm running node in strict mode and I'm getting
/apiserver/node_modules/mongoose-shortid/lib/index.js:6
for (fieldName in this.schema.tree) {
^
ReferenceError: fieldName is not defined
at model.mongoose.Model.save (/apiserver/node_modules/mongoose-shortid/lib/index.js:6:32)
at model._done (/apiserver/node_modules/mongoose/node_modules/hooks/hooks.js:59:24)
at _next (/apiserver/node_modules/mongoose/node_modules/hooks/hooks.js:52:28)
at fnWrapper (/apiserver/node_modules/mongoose/node_modules/hooks/hooks.js:159:8)
at model.<anonymous> (/apiserver/node_modules/mongoose-schema-extend/index.js:44:7)
at _next (/apiserver/node_modules/mongoose/node_modules/hooks/hooks.js:50:30)
at fnWrapper (/apiserver/node_modules/mongoose/node_modules/hooks/hooks.js:159:8)
at model.<anonymous> (/apiserver/node_modules/mongoose-schema-extend/index.js:44:7)
at _next (/apiserver/node_modules/mongoose/node_modules/hooks/hooks.js:50:30)
at fnWrapper (/apiserver/node_modules/mongoose/node_modules/hooks/hooks.js:159:8)
In strict mode, the problem is easily fixed by writing for (let fieldName ...
instead (but let
doesn't work in legacy mode, of course). Maybe you could check for strict mode, or traverse the schema some other way?