如何查找没有joinWaterline ORM的logging

我正在使用node.js框架,Sails JS,以及其内置的ORM Waterline for Tinder-like项目。

我不知道如何编写我的查询来获取未join的logging。 在我的情况下,当用户“喜欢”或“不喜欢”另一个用户的个人资料时,我希望喜欢的个人资料不再显示。

我如何做到这一点? 这是我迄今为止所尝试的:

 Cat.query('select cat.* from cat left outer join vote on cat.id = vote.owner where vote.owner is null AND cat.id !='+req.session.User.id, function (err, results) { if (err) return res.serverError(err); res.send('Yes'); console.log(results); }); 

如果我得到你的权利, 是用户configuration文件? 所以,我们需要configuration文件:

  1. 不属于当前用户( cat.id !== req.session.User.id
  2. 不喜欢或不喜欢当前用户。

     var query = 'select cat.* ' + ' from cat left join vote on' + // joining votes for current user ' cat.id = vote.catId and vote.owner = ' + req.session.User.id + ' where' + // filtering out the Cat with current user Id (if needed) ' cat.id <> ' + req.session.User.id + ' and' + // leaving only records with empty vote id(meaning there's no corresponding vote record) ' vote.id is null'; 

用于更多crear视图的纯SQL:

 select cat.* from cat left join vote on cat.id = vote.catId and vote.owner = :userId where cat.id <> :userId and vote.id is null 

我们从表中select所有loggingjoin当前用户为他们做的投票。 然后只保留缺less选票的logging,以及id <>当前用户标识