Expected behavior
While running on Version 7, I used the following function to update smart fields.
function updateTranslation(params) {
let { label, value, field } = params;
console.log("params: ", params);
return new ResourceGetter(Label, { recordId: label.id })
.perform()
.then((foundLabel) => {
return Translation.findOne({
where: { translationKey: foundLabel.key },
});
})
.then((foundTranslation) => {
foundTranslation[field] = value;
foundTranslation.save();
return foundTranslation;
});
}
Actual behavior
The code is throwing an error when executing .perform()
Failure Logs
Unhandled rejection TypeError: Cannot read property 'renderingId' of undefined
at ScopeManager._callee2$ (/Users/camillefeghali/dev/foxxbee/forest-api/node_modules/forest-express/dist/services/scope-manager.js:92:26)
at tryCatch (/Users/camillefeghali/dev/foxxbee/forest-api/node_modules/regenerator-runtime/runtime.js:63:40)
at Generator.invoke [as _invoke] (/Users/camillefeghali/dev/foxxbee/forest-api/node_modules/regenerator-runtime/runtime.js:294:22)
at Generator.next (/Users/camillefeghali/dev/foxxbee/forest-api/node_modules/regenerator-runtime/runtime.js:119:21)
at asyncGeneratorStep (/Users/camillefeghali/dev/foxxbee/forest-api/node_modules/@babel/runtime/helpers/asyncToGenerator.js:3:24)
at _next (/Users/camillefeghali/dev/foxxbee/forest-api/node_modules/@babel/runtime/helpers/asyncToGenerator.js:25:9)
at /Users/camillefeghali/dev/foxxbee/forest-api/node_modules/@babel/runtime/helpers/asyncToGenerator.js:32:7
at new Promise (<anonymous>)
at ScopeManager.<anonymous> (/Users/camillefeghali/dev/foxxbee/forest-api/node_modules/@babel/runtime/helpers/asyncToGenerator.js:21:12)
at ScopeManager.getScopeForUser (/Users/camillefeghali/dev/foxxbee/forest-api/node_modules/forest-express/dist/services/scope-manager.js:125:33)
at ResourceGetter.perform (/Users/camillefeghali/dev/foxxbee/forest-api/node_modules/forest-express-sequelize/dist/services/resource-getter.js:26:60)
at updateTranslation (/Users/camillefeghali/dev/foxxbee/forest-api/forest/label.js:31:6)
at Object.set (/Users/camillefeghali/dev/foxxbee/forest-api/forest/label.js:10:7)
at /Users/camillefeghali/dev/foxxbee/forest-api/node_modules/forest-express/dist/deserializers/resource.js:47:22
From previous event:
at processImmediate (internal/timers.js:439:21)
From previous event:
at extractAttributes (/Users/camillefeghali/dev/foxxbee/forest-api/node_modules/forest-express/dist/deserializers/resource.js:44:14)
at ResourceDeserializer.perform (/Users/camillefeghali/dev/foxxbee/forest-api/node_modules/forest-express/dist/deserializers/resource.js:96:12)
at Resources.update (/Users/camillefeghali/dev/foxxbee/forest-api/node_modules/forest-express/dist/routes/resources.js:98:81)
at Layer.handle [as handle_request] (/Users/camillefeghali/dev/foxxbee/forest-api/node_modules/express/lib/router/layer.js:95:5)
at next (/Users/camillefeghali/dev/foxxbee/forest-api/node_modules/express/lib/router/route.js:137:13)
at _callee$ (/Users/camillefeghali/dev/foxxbee/forest-api/node_modules/forest-express/dist/middlewares/permissions.js:117:19)
at tryCatch (/Users/camillefeghali/dev/foxxbee/forest-api/node_modules/regenerator-runtime/runtime.js:63:40)
at Generator.invoke [as _invoke] (/Users/camillefeghali/dev/foxxbee/forest-api/node_modules/regenerator-runtime/runtime.js:294:22)
at Generator.next (/Users/camillefeghali/dev/foxxbee/forest-api/node_modules/regenerator-runtime/runtime.js:119:21)
at asyncGeneratorStep (/Users/camillefeghali/dev/foxxbee/forest-api/node_modules/@babel/runtime/helpers/asyncToGenerator.js:3:24)
at _next (/Users/camillefeghali/dev/foxxbee/forest-api/node_modules/@babel/runtime/helpers/asyncToGenerator.js:25:9)
Context
Could this be cause by the upgrade to version 8 ?
- Package Version: ^8.0.5
- Express Version: ^4.17.1
- Sequelize Version: ^6.6.2
- Database Dialect: postgres
- Database Version: 11
- Project Name: forest-api