Skip to content
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

patch() method doesn't call 'patched' event handler. #39

Closed
palavrov opened this issue Sep 20, 2016 · 6 comments
Closed

patch() method doesn't call 'patched' event handler. #39

palavrov opened this issue Sep 20, 2016 · 6 comments

Comments

@palavrov
Copy link

It is difficult to extract example from my code but seems that patched event handler is not called when patching records with query. Neither the REST API updates web clients when patching.

Could some one please explain me how patch method should work? I'm lost in the code and don't have time to figure it out myself right now in order to debug it deeper. Thanks.

@marshallswain
Copy link
Member

@palavrov I suspect that this has something to do with something in the app preventing it from happening. If you do a simple test on a new, fresh service, do you get the same result?

@palavrov
Copy link
Author

@marshallswain I'm debugging that right now and just find a workaround which seems to work for me, here is the code:

var removeCableZones = function(zoneId) {
    /* TODO: NeDB patch doesn't call 'patched' event handlers and doesn't
     * notify web clients about patches.

    return cablesService.patch( null, { zoneId: null }, { query: { zoneId: zoneId } });

    */

    return cablesService.find({
        query: {
            zoneId: zoneId
        }
    }).then(function(cables) {
        var actions = [];

        cables = [].concat(cables);

        cables.forEach(function(cable) {
            cable.zoneId = null;

            var action = cablesService.update(cable._id, cable);

            actions.push(action);
        });

        return Promise.all(actions);
    });
};

As you can see emulating patch with update works as expected.

@marshallswain
Copy link
Member

marshallswain commented Sep 20, 2016

Latest versions of everything? npm outdated and let me know, please. I'm going to make a quick test for this right now, locally.

@palavrov
Copy link
Author

palavrov@palavrov-2:~/codigi/ttk/ttk-web$ npm outdated
Package            Current  Wanted        Latest  Location
angular-ui-router    0.3.1   0.3.1  1.0.0-beta.2  TTKweb
feathers             2.0.1   2.0.2         2.0.2  TTKweb
feathers-client      1.5.3   1.6.1         1.6.1  TTKweb
feathers-rest        1.4.4   1.5.0         1.5.0  TTKweb
html-loader          0.4.3   0.4.4         0.4.4  TTKweb
node-fetch           1.6.0   1.6.1         1.6.1  TTKweb
validator            5.6.0   5.7.0         5.7.0  TTKweb

@daffl
Copy link
Member

daffl commented Sep 20, 2016

The problem is probably feathersjs/feathers#393

@palavrov
Copy link
Author

Indeed, seems exactly the same. Let's close this then.

I was not expecting so quick reaction so:

GUYS, YOU ARE AWESOME !!! FEATHERSJS REALLY ROCKS !!!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants