{"action":"created","issue":{"url":"https://api.github.com/repos/sequelize/sequelize/issues/4099","labels_url":"https://api.github.com/repos/sequelize/sequelize/issues/4099/labels{/name}","comments_url":"https://api.github.com/repos/sequelize/sequelize/issues/4099/comments","events_url":"https://api.github.com/repos/sequelize/sequelize/issues/4099/events","html_url":"https://github.com/sequelize/sequelize/issues/4099","id":94623669,"number":4099,"title":"\"exclude\" instead of \"include\" / find where not exists","user":{"login":"tommedema","id":331833,"avatar_url":"https://avatars.githubusercontent.com/u/331833?v=3","gravatar_id":"","url":"https://api.github.com/users/tommedema","html_url":"https://github.com/tommedema","followers_url":"https://api.github.com/users/tommedema/followers","following_url":"https://api.github.com/users/tommedema/following{/other_user}","gists_url":"https://api.github.com/users/tommedema/gists{/gist_id}","starred_url":"https://api.github.com/users/tommedema/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tommedema/subscriptions","organizations_url":"https://api.github.com/users/tommedema/orgs","repos_url":"https://api.github.com/users/tommedema/repos","events_url":"https://api.github.com/users/tommedema/events{/privacy}","received_events_url":"https://api.github.com/users/tommedema/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"milestone":null,"comments":4,"created_at":"2015-07-13T02:33:27Z","updated_at":"2015-07-27T13:40:16Z","closed_at":"2015-07-13T07:11:32Z","body":"The following:\r\n\r\n        User.findAndCountAll({\r\n\t\t  include: [\r\n\t\t     { model: Profile, required: true}\r\n\t\t  ]\r\n\t\t});\r\n\r\nWill return users that have a profile.\r\n\r\nHow do I return users that have no profile? Is there an `exclude`?\r\n\r\nAlso, can I perform additional `where` statements on the relation? E.g. I want to return all users that have no profile with an avatar. Something like this?\r\n\r\n        User.findAndCountAll({\r\n\t\t  include: [\r\n\t\t     { model: Profile, required: true, where: {avatar: null}}\r\n\t\t  ]\r\n\t\t});"},"comment":{"url":"https://api.github.com/repos/sequelize/sequelize/issues/comments/125207279","html_url":"https://github.com/sequelize/sequelize/issues/4099#issuecomment-125207279","issue_url":"https://api.github.com/repos/sequelize/sequelize/issues/4099","id":125207279,"user":{"login":"slawo","id":341609,"avatar_url":"https://avatars.githubusercontent.com/u/341609?v=3","gravatar_id":"","url":"https://api.github.com/users/slawo","html_url":"https://github.com/slawo","followers_url":"https://api.github.com/users/slawo/followers","following_url":"https://api.github.com/users/slawo/following{/other_user}","gists_url":"https://api.github.com/users/slawo/gists{/gist_id}","starred_url":"https://api.github.com/users/slawo/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/slawo/subscriptions","organizations_url":"https://api.github.com/users/slawo/orgs","repos_url":"https://api.github.com/users/slawo/repos","events_url":"https://api.github.com/users/slawo/events{/privacy}","received_events_url":"https://api.github.com/users/slawo/received_events","type":"User","site_admin":false},"created_at":"2015-07-27T13:40:16Z","updated_at":"2015-07-27T13:40:16Z","body":"I have a big issue with this. Doing: \r\n````\r\nUser.findAll({\r\n    where: sequelize.literal('profiles.userId IS null'),\r\n    include: [\r\n    { model: Profile}\r\n    ]\r\n  })\r\n````\r\nWorks OK. But now try :\r\n````\r\nUser.findAndCountAll({\r\n    where: sequelize.literal('profiles.userId IS null'),\r\n    include: [\r\n    { model: Profile}\r\n    ]\r\n  })\r\n````\r\n\r\nAnd observe the crash..."}}