Skip to content

doesNotMatchKeyInQuery doesn't work when using same query and key with different query key #621

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

Closed
tgreco opened this issue Aug 2, 2018 · 4 comments

Comments

@tgreco
Copy link

tgreco commented Aug 2, 2018

My schema:

Match: 
scheduledBy (Pointer to user) 
scheduledWith (Pointer to user)

Photo: 
owner (Pointer to user)

I want to find photos for users that do not have any matches.

What I tried:

 let photoQuery = new Parse.Query(MODEL.Photo.className());
photoQuery.include('owner');

// Do not include people who have matches
let matchQuery = new Parse.Query(MODEL.Match.className());
photoQuery.doesNotMatchKeyInQuery('owner', 'scheduledBy', 	matchQuery);
photoQuery.doesNotMatchKeyInQuery('owner', 'scheduledWith', matchQuery);

// Get final results
return photoQuery.find()

This only works for the scheduledBy column.

Seems like you can't do doesNotMatchKeyInQuery with the same key and query but different query keys for some odd reason.

Can anyone confirm this? If so what would be the best alternative?

I removed scheduledBy and used scheduledWith only and that worked as well. So it's not something wrong with the data it's a bug with Parse I believe.

@flovilmart
Copy link
Contributor

Thanks for your question!

We want to make sure to keep signal strong in the GitHub issue tracker – to make sure that it remains the best place to track issues that affect the development of Parse Server.

Questions like yours deserve a purpose-built Q&A forum. Would you like to post this question to Stack Overflow with the tag #parse.com? We'll be happy to answer there. Post a link to your Stack Overflow question here, so that we don't lose track of it.

You may also use Server Fault for questions about managing your own servers.

@tgreco
Copy link
Author

tgreco commented Aug 3, 2018

@dplewis
Copy link
Member

dplewis commented Aug 3, 2018

@tgreco I don’t think you can use it twice in the same query. One will override the other because it’s key value and you can have one key in this case owner. Try using an and query. It’s still knew so it may not work.

@tgreco
Copy link
Author

tgreco commented Aug 3, 2018

@dplewis my issue with a compound query is that this query is much more complex and uses GeoPoints and near in a subquery so I cannot include that in my compound query as the documentation says:

Note that we do not support GeoPoint or non-filtering constraints (e.g. near, withinGeoBox, limit, skip, ascending/descending, include) in the subqueries of the compound query.

let matchQuery = new Parse.Query(MODEL.Match.className());

let photoQuery1 = new Parse.Query(MODEL.Photo.className());
photoQuery1.doesNotMatchKeyInQuery('owner', 'scheduledBy', 	matchQuery);

let photoQuery2 = new Parse.Query(MODEL.Photo.className());
photoQuery2.doesNotMatchKeyInQuery('owner', 'scheduledWith', matchQuery);

// Contains all default photos of people without matches 
let compoundPhotoQuery = new Parse.Query.and(photoQuery1, photoQuery2);

// TODO: mainPhotoQuery.matches(compoundPhotoQuery); ?

How could I include compoundPhotoQuery into the main PhotoQuery now?
I'm not sure it's possible to do a matchesQuery or containedIn on the actual object rather than a specific key in the object is there?

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

3 participants