feathers-reactive
feathers-reactive copied to clipboard
"smart" listStrategy patch updates undo $populate relationships
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 thealwaysstrategy can be used).
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.
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.