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

"smart" listStrategy patch updates undo $populate relationships #118

Open
akagomez opened this issue Jun 13, 2018 · 2 comments
Open

"smart" listStrategy patch updates undo $populate relationships #118

akagomez opened this issue Jun 13, 2018 · 2 comments

Comments

@akagomez
Copy link

akagomez commented Jun 13, 2018

Given a Mongoose service configured for relationships with { ref: 'modelName' }, when subscribing via a .find() query that includes the special $populate parameter, and a patch update is received, the record is overwritten with the update (as opposed to merged) and the related (ref) record data is replaced with its ObjectId.

So while you may initially get this list in your .find({ $populate: 'post' }).subscribe(fn) handler:

[
  { 
    comment: 'Feathers is so cool',
    post: {
      _id: '1afsd09fj2e92f09qjf09234f',
      slug: 'cool-feathers-features'
    }
  }
]

A patch to one of the query results will become this:

[
  { 
    comment: 'Feathers is so cool',
    post: '1afsd09fj2e92f09qjf09234f'
  }
]

That said, this problem can be addressed with .watch({ listStrategy: 'always' }).

Not sure if this case is expected based on this statement from the documentation:

smart (default) - Returns a stream that smartly emits updated list data based on the services real-time events. It does not re-query any new data (but does not cover some cases in which the always strategy can be used).

@daffl
Copy link
Member

daffl commented Aug 25, 2018

This can probably also be solved with adding the $populate query parameter to the patch request. Basically you want it to return the same data.

@stale
Copy link

stale bot commented Nov 17, 2018

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Apologies if the issue could not be resolved. FeathersJS ecosystem modules are community maintained so there may be a chance that there isn't anybody available to address the issue at the moment. For other ways to get help see here.

@stale stale bot added the wontfix label Nov 17, 2018
@daffl daffl added enhancement and removed wontfix labels Nov 17, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants