I'm working on express.js framework and sequlize.js orm.
I get the region and the type from the back-end.
Using those two variables I want to construct an object to pass to the sequlize orm.
let region_id = req.swagger.params.region_id.value;
let type = req.swagger.params.type.value;
console.log("REGION", region_id) // will output 4,5,6,... etc
console.log("TYPE", type) // will output is_lunch,is_dinner,... etc
That was my variables.
This is my object
const prepared_query = {
where:{
},
attributes: ['price'],
include: [{
model: db.restaurants,
attributes: ['region_id'],
where: {
region_id: ''
}
}]
}
prepared_query.include[0].where.region_id = region_id;
prepared_query.where[type] = true;
prepared_query.include[0].where.region_id = region_id;
successfully replaced the region_id as 4. but
prepared_query.where[type] = true;
is not gives me is_lunch:true'
instead it gives me Cannot set property 'is_lunch' of undefined
HOW DO I ACHIEVE THIS USING JAVA SCRIPT?