Parse-server: Running LiveQuery with matchesQuery returns no results.

Created on 26 Oct 2016  路  16Comments  路  Source: parse-community/parse-server

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

Most helpful comment

@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鈥檙e welcome to submit a PR or join discussions on the community forum, but please be respectful.

All 16 comments

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

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

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

Awesome! Excited to see that one land!

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

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

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?

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?

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

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

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

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.

Any plan to support parselivequery on parserelation?

Would love to see that feature

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

@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鈥檙e welcome to submit a PR or join discussions on the community forum, but please be respectful.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

omyen picture omyen  路  3Comments

jaydeep82 picture jaydeep82  路  4Comments

kilabyte picture kilabyte  路  4Comments

ViolentCrumble picture ViolentCrumble  路  3Comments

sanergulec picture sanergulec  路  4Comments