Skip to content

Instantly share code, notes, and snippets.

@todgru
Created November 15, 2017 00:03
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save todgru/ea8a44d3eb6f6dd5f5fcca40e210a36f to your computer and use it in GitHub Desktop.
Save todgru/ea8a44d3eb6f6dd5f5fcca40e210a36f to your computer and use it in GitHub Desktop.
sequelize through table this is how a query on a column of a through table works. can't query directly on the through table.
this.models.myItem.findAll({
where: { projectId: 1 },
include: [
{
model: this.models.myItemThing,
// Sequelize term indicates "use the through table where `type===foo`"
through: {
where: { type: "foo" },
},
},
],
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment