I have a sequelize based backend express API. In my sequelize models, a Citizen
belongs to a Street
which belongs to a Town
, which belongs to a State
. I can count the citizens in a Street
easily like:
return db.Citizen.aggregate('value', 'count', {
where: {
'$Town.name$': townName
},
});
However, I would like to be able to count the citizens in a Town
or State
, even though Citizens aren't directly associated with those models. Is that possible and if so, how could I do it?
via George Edwards
No comments:
Post a Comment