-
-
Notifications
You must be signed in to change notification settings - Fork 750
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Patching multiple records that update the queried value doesn't emit any service events #393
Comments
Ok... I figured it out. A workaround could be this (I wrote this in the compiled ES5 file) in NeDB::patch function patch(id, data, params) {
var _this = this;
var _multiOptions = (0, _utils.multiOptions)(id, this.id, params);
var query = _multiOptions.query;
var options = _multiOptions.options;
// Run the query
return (0, _utils.nfcall)(this.Model, 'update', query, {
$set: (0, _lodash2.default)(data, this.id, '_id')
}, options).then(function () {
Object.keys(params.query).forEach(key => {
if (data.hasOwnProperty(key)) {
params.query[key] = data[key];
}
});
return _this._findOrGet(id, params);
});
} |
Good catch. Might be tricky to fix though because you'd have to know how the database is querying records (e.g. in MongoDB we'd have to turn the new data into a dot-notation query). Ideally the db would return all changed records (or at least the id of all changed records) but SQL dbs seem to make that a little more difficult. |
Tests have been added in feathersjs-ecosystem/feathers-service-tests@af1add3 and fixed and released in all official adapters. |
This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue with a link to this issue for related bugs. |
I tried this with the Mongoose and the NeDB service.
patched
event to a callback:number
property of all entries who has thetext: 'Test 1'
:The patch was successful in DB, the event-callback is fired for 3 times and the promise was resoved with an array[3].
text: 'Test 1'
totext: 'Test 2'
The patch in the DB was successful, but no event was fired and the resolved promise contains an empty array.
The text was updated successfully, but these errors were encountered: