Created
July 9, 2015 14:05
-
-
Save jwhitmarsh/d24ae49a92964192d6a9 to your computer and use it in GitHub Desktop.
Sequelize left join from two tables
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Extraction.findAll({ | |
where: { | |
archived: false | |
}, | |
attributes: ['id', 'createdAt', 'updatedAt'], | |
include: [ | |
{ | |
model: ExtractionTemplate, | |
attributes: ['id'], | |
where: { | |
extractionTemplateTypeId: id | |
}, | |
include: [ | |
{ | |
model: FieldCategory, | |
attributes: ['id'], | |
where: { | |
parentId: null | |
}, | |
required: false, | |
include: [ | |
{ | |
model: Field, | |
attributes: ['id', 'label', 'isBaseline'], | |
where: { | |
isBaseline: true | |
}, | |
required: false, | |
include: [ | |
{ | |
model: FieldValue, | |
attributes: ['id', 'value', 'extractionId'], | |
where: { | |
extractionId: 0 // I NEED TO GET THE EXTRACTION ID HERE | |
}, | |
required: false | |
} | |
] | |
} | |
] | |
} | |
] | |
} | |
], | |
raw: raw | |
}).then(function(extractions) { | |
cb(0, extractions); | |
}).catch(function(err) { | |
app.log.error('Extractions getAll error:' + err.message); | |
cb(err); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment