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

Running LiveQuery with matchesQuery returns no results. #2946

Closed
danibjor opened this issue Oct 26, 2016 · 16 comments
Closed

Running LiveQuery with matchesQuery returns no results. #2946

danibjor opened this issue Oct 26, 2016 · 16 comments

Comments

@danibjor
Copy link

danibjor commented Oct 26, 2016

Issue Description

Running LiveQuery with matchesQuery returns no results - if the same Query is executed with find( .. ), results are returned.

Steps to reproduce

    var d = new Date();
    var time = (1 * 12 * 60 * 60 * 1000);
    var expirationDate = new Date(d.getTime() - (time));

    var query = new Parse.Query('Radio');
    var innerQuery = new Parse.Query('RadioLocation');

    innerQuery.greaterThanOrEqualTo("gpsDate", expirationDate);
    query.matchesQuery("latestLocation", innerQuery);

    console.log('subscribing for locations', expirationDate);

    var subscription = query.subscribe();

Running the query in Chrome console (chrome dev tools)

var d = new Date();
    var time = (1 * 12 * 60 * 60 * 1000);
    var expirationDate = new Date(d.getTime() - (time));

    var query = new Parse.Query('Radio');
    var innerQuery = new Parse.Query('RadioLocation');

    innerQuery.greaterThanOrEqualTo("gpsDate", expirationDate);
    query.matchesQuery("latestLocation", innerQuery);

query.find({
  success: function(res) {
    console.log("res", res.length, res);
  }
});

returns

ParsePromise {_resolved: false, _rejected: false, _resolvedCallbacks: Array[0], _rejectedCallbacks: Array[0]}
VM4688:13 
(string) res 
(int) 12 
(array) [ParseObject, ParseObject, ParseObject, ParseObject, ParseObject, ParseObject, ParseObject, ParseObject, ParseObject, ParseObject, ParseObject, ParseObject]

So, the query returns expected results when .find() is executed - but no events when using LiveQuery. If I remove the innerQuery and filter on Radio.UpdatedAt, events are fired - so LiveQuery are working.

Expected Results

Events triggered when RadioLocation gets new items

Actual Outcome

No events gets triggered

Environment Setup

  • Server
    • parse-server version 2.2.23
    • Operating System: docker container
    • Hardware: Running in Ubuntu 14.4 container, in VirtualBox, on iMac OSX v.Latest
    • Localhost or remote server? Dev setup
  • Database
    • MongoDB version: Running docker cluster, v3.2
    • Hardware: Same docker swarm as above
    • Localhost or remote server? Same as above
@danibjor
Copy link
Author

danibjor commented Nov 1, 2016

So, I guess relation queries are not supported on subscribe/liveQuery?

@flovilmart
Copy link
Contributor

It seems that it's not supported yet. Do you want to try to add that support?

@danibjor
Copy link
Author

danibjor commented Nov 1, 2016

I still don't speak fluent Parse, but I could give it a go.

@flovilmart
Copy link
Contributor

Awesome! Excited to see that one land!

@dpoetzsch
Copy link

@danibjor I just stumbled over the same problem, how's your progress on supporting this feature?

@danibjor
Copy link
Author

@dpoetzsch Not too good - need to find time to better understand everything that is involved, so I don't break anything..

@dpoetzsch
Copy link

So I investigated a bit today. I would guess that basically we would have to add a case in the switch statement in QueryTools.js, line 279 for $inQuery. The problem is that we would have to execute the query in this case making the whole thing asynchronous. Also the overhead seems to be significant: For each change in the table we would need to execute a query.

Any ideas maybe on how to make this more efficient?

@flovilmart
Copy link
Contributor

The overhead is effectively significant. But that probably can be logged as a warning when subscribing to that kind of query. Moreover if the secondary table is improperly indexed.
After all, as a developer, you can probably work around that performance hit by optimizing the data relationship right?

@flovilmart
Copy link
Contributor

Also, you can use async/await to check the query match in that case, as babel will transpile to yield that should be supported in node 4.5

@flovilmart
Copy link
Contributor

I'll give it a try with async/await and the additional required read..

@malhal
Copy link

malhal commented Dec 27, 2016

Subscribe to RadioLocation instead, where the Radio ID is in an array of IDs.

@flovilmart
Copy link
Contributor

Closing due to lack of activity, please update to latest parse-server version and open a new issue if the issue persist.

Also, for now, LiveQuery don't support complex queries that would require additional access to the database.

@Edijae
Copy link

Edijae commented Oct 15, 2019

Any plan to support parselivequery on parserelation?

@RaveKev
Copy link

RaveKev commented Apr 26, 2020

Would love to see that feature

@facuparedes
Copy link

Wow, 4 years and they don't added requested feature. Nice.

@dblythy
Copy link
Member

dblythy commented Aug 13, 2020

@FNPCMDs I will give this a crack, be mindful parse is a community based project that requires contributions from people who need features for their own projects. You’re welcome to submit a PR or join discussions on the community forum, but please be respectful.

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

8 participants