I upgraded my feathersjs version from 2.x.x to 3.9.0 Now I have a problem with hooks (after)
this is my query:
app.service('duties').patch(id, { $set: { status: 0 }}, {});
I have below code in my hook after:
var query = { "duties._id": result._id }
hook.app.service('parents').patch(null, { $set: { "duties.$.status": 0 } }, { query });
With previously version this was work fine, now I receive an error in console:
error: MethodNotAllowed: Can not patch multiple entries
How can I resolve my problem?
In order to improve out-of-the-box security, creating, removing and modifying multiple entries has been disabled by default and has to be enabled using the multi
option (and secured explicitly). The migration instructions can be found at crow.docs.feathersjs.com/migrating.html#database-adapters:
const service = require('feathers-<database>');
// Allow multi create, patch and remove
service({
multi: true
});
// Only allow create with an array
service({
multi: [ 'create' ]
});
// Only allow multi patch and remove (with `id` set to `null`)
service({
multi: [ 'patch', 'remove' ]
});
Keep in mind that when enabling multiple remove
or patch
requests the allowed query must be restricted (e.g. based on the authenticated user id), otherwise it could be possible to delete or patch every record in the database.
It can be corrected/enabled (e.g for patch) here
\\ @Src/services/[name]/[name].service.js
.
.
.
module.exports = function(app) {
Const options = {
Model: createModel(app),
Paginate: app.get('paginate'),
multi: ['patch']
};
.
.
.
},
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With