简体   繁体   English

解析云代码DidNotMatchKey

[英]Parse Cloud Code DoesNotMatchKey

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. 这仅适用于scheduleBy列。

Seems like you can't do doesNotMatchKeyInQuery with the same key and query but different query keys for some odd reason. 似乎您不能使用相同的键和查询但由于某些奇怪的原因而使用不同的查询键来执行dosNotMatchKeyInQuery。

Can anyone confirm this? 有人可以确认吗? If so what would be the best alternative? 如果是这样,什么是最佳选择?

I removed scheduledBy and used scheduledWith only and that worked as well. 我删除了chedchedBy,只使用了cheduleWith,效果也很好。 So it's not something wrong with the data it's a bug with Parse I believe. 因此,我认为数据没有错,这是Parse的错误。

I think you're on the right track, but I think the problem is the use of a single inner query to qualify two fields on the main query. 我认为您走在正确的道路上,但我认为问题在于使用单个内部查询来限定主查询中的两个字段。 This is more of a hunch, but I think you'll get the result you seek with... 这有点预感,但是我想您会得到想要的结果...

// use a distinct instance of an inner query for each test in the outer query
let matchQueryBy = new Parse.Query(MODEL.Match.className());
let matchQueryWith = new Parse.Query(MODEL.Match.className());

photoQuery.doesNotMatchKeyInQuery('owner', 'scheduledBy',   matchQueryBy);
photoQuery.doesNotMatchKeyInQuery('owner', 'scheduledWith', matchQueryWith);

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM