Adds option to write a condition for the include query so that one can make a call as follows
Adds strict property that changes OPTIONAL MATCH to MATCH for relationship selection if set to true
const opts = {
varName: 'person',
include: {
'Student': {
model: Student, // assume imported at the top
relName: 'IS_STUDENT_OF',
many: true,
strict: true,
where: { university: 'LP' }
}
}
};
Person.findAll(opts, function(err, results) {
// will result return only Persons that have a relation to Student with a `university` property === 'LP'
})
supports multiple include queries
Additionally this PR adds in option for the query condition, example with multiple queries and in statement below
const opts = {
varName: 'person',
include: {
'Student': {
model: Student, // assume imported at the top
relName: 'IS_STUDENT_OF',
many: true,
strict: true,
where: { university: 'LP' }
},
'City': {
model: City, // assume imported at the top
relName: 'IS_CITY',
many: true,
strict: true,
where: { name: ['Lviv', 'Kyiv', 'Bergen'] }
}
}
};
Person.findAll(opts, function(err, results) {
// will result return only Persons that have a relation to Student with a `university` property === 'LP'
// and with has relation to City with `name` value in `['Lviv', 'Kyiv', 'Bergen']`
})
if strict option is not set OPTIONAL MATCH will be performed, so that all the records for the Person will be returned, and only those that have relation will be extended.
The only restriction is that all the strict include relations should be placed before the non-strict ones, as MATCH can't follow OPTIONAL MATCH
Adds option to write a condition for the include query so that one can make a call as follows Adds
strict
property that changesOPTIONAL MATCH
toMATCH
for relationship selection if set totrue
supports multiple include queries Additionally this PR adds
in
option for the query condition, example with multiple queries andin
statement belowif
strict
option is not setOPTIONAL MATCH
will be performed, so that all the records for the Person will be returned, and only those that have relation will be extended. The only restriction is that all thestrict
include relations should be placed before the non-strict ones, asMATCH
can't followOPTIONAL MATCH
All tests are passing