Closed maxinminax closed 2 years ago
What is the use-case when the original code is wrong?
What is the use-case when the original code is wrong?
When I disable some service actions via createActions
option
As in the document:
module.exports = {
mixins: [DbService({
createActions: {
find: false,
replace: false
}
})]
}
If createActions
is a Object, actionEnabled
will always return true and all actions will be created
Because default value of createActions
is true
, so I have updated my resolve:
const actionEnabled = name => {
if (typeof mixinOpts.createActions === "object") {
return mixinOpts.createActions[name] !== false;
}
return mixinOpts.createActions !== false;
};
You are right, thanks. I'm fixing...
What is the use-case when the original code is wrong?
When I disable some service actions via
createActions
option As in the document:module.exports = { mixins: [DbService({ createActions: { find: false, replace: false } })] }
If
createActions
is a Object,actionEnabled
will always return true and all actions will be created Because default value ofcreateActions
istrue
, so I have updated my resolve:const actionEnabled = name => { if (typeof mixinOpts.createActions === "object") { return mixinOpts.createActions[name] !== false; } return mixinOpts.createActions !== false; };
sorry but I have updated my resolve, because default actions is will be created, so must be check it's not false (set false to disable): mixinOpts.createActions[name] !== false
As the case in document:
module.exports = {
mixins: [DbService({
createActions: {
find: false,
replace: false
}
})]
}
No action is true
in the createActions object, so don't have any actions will be create
Could you please open a PR with your solution? Thanks in advance
https://github.com/moleculerjs/database/blob/ed33d2dcbacb6d3ac8793e0698e1a9c5e71d008d/src/actions.js#L55-L60
it must be: