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

$or filter doesn't work on watch/subscribe #139

Open
adrianolsk opened this issue Oct 11, 2018 · 1 comment
Open

$or filter doesn't work on watch/subscribe #139

adrianolsk opened this issue Oct 11, 2018 · 1 comment
Labels

Comments

@adrianolsk
Copy link

I am using feathers-reactive,
to get some data from a service and I subscribe to the result. When someone invites the user or he invites someone he should receive the updated data.
It does work when I specify the user_id in the query, but if I use a $or he starts to receive updates from all users all over the app

this.app
   .service("friends")
   .watch()
   .find({
       query: { 
           $or: [{ user_id: user.id }, { friend_id: user.id }] // this doesn't work
           // user_id: user.id // this work
       }
   })
   .subscribe(friends => console.log(friends));

Expected behavior

It should respect the filter

Actual behavior

It completely ignores the filter when using a $or

More context

I am posting a simple object like this using postman:

{
    "user_id": 1,
    "friend_id": 2,
    "accepted": true
}

workaround

The thing I did to workaround was using channels to only publish the data if the user is in one of the fields:

// app.on("login", (authResult, { connection }) => {...
 app.channel(`friends/${connection.user.id}`).join(connection);

//publish
app.service("friends").publish(data => {
    return [
      app.channel(`friends/${data.user_id}`),
      app.channel(`friends/${data.friend_id}`)
    ];
});
@daffl daffl added the bug label Nov 6, 2018
@Artaud
Copy link

Artaud commented Oct 14, 2020

Has this been resolved and forgotten or is it still present?

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

No branches or pull requests

3 participants