我有这段代码与php配合得很好
$rs = mysqli_query($conn,"select b.idagence from booking_btb b where b.status='booking' group by b.idagence order by $sort $order ");
$rows = array();
$i=0;
while($row = mysqli_fetch_object($rs)){
array_push($rows, $row);
$idagence =$row->idagence;
$rsi=mysqli_query($conn,"select sum(montant_a) from booking_btb where idagence=$idagence and etat=0 ");
...
}
Sequelieze是Node.js中数据库ORM映射的绝佳工具, 我需要用NodeJs实现并续集 我开始做,但是我做不到
stat_agence(req, res) {
return booking_btb
.findAll({
where: {
status: 'booking'
},
attributes: {
exclude: ['idsession','idperiod_debut','email','createdAt','updatedAt'],
include: [
{
model:agence,
attributes: [['username', 'username'],'id']
} ,
{
model:hotel,
attributes: [['nom', 'nom'],'idhotel']
}
],
group:agence.id
}
)
.then(booking_btb =>{
for (s=0;s<booking_btb.length;s++)
{
idagence=booking_btb[s]['dataValues']['idagence'];
}
res.status(200).send(booking_btb)
}
)
.catch(error => res.status(400).send(error));
},
想在您的帮助下