Why iterator is stuck on index 0?

i have a query like this
const q = db
.select()
.from(tpsReports)
.orderBy(desc(tpsReports.created_at))
.leftJoin(subDistricts, eq(tpsReports.kel_id, subDistricts.id))
.leftJoin(districts, eq(subDistricts.idKec, districts.id))
.leftJoin(regencies, eq(districts.idKab, regencies.id))
.leftJoin(provinces, eq(regencies.idProv, provinces.id))
.where(eq(provinces.id, sql.placeholder('province_id')))
.limit(12)
.prepare();

const provincesIter = db.select().from(provinces).iterator();
for await (const province of provincesIter) {
await q.execute({ province_id: province.id });
}
const q = db
.select()
.from(tpsReports)
.orderBy(desc(tpsReports.created_at))
.leftJoin(subDistricts, eq(tpsReports.kel_id, subDistricts.id))
.leftJoin(districts, eq(subDistricts.idKec, districts.id))
.leftJoin(regencies, eq(districts.idKab, regencies.id))
.leftJoin(provinces, eq(regencies.idProv, provinces.id))
.where(eq(provinces.id, sql.placeholder('province_id')))
.limit(12)
.prepare();

const provincesIter = db.select().from(provinces).iterator();
for await (const province of provincesIter) {
await q.execute({ province_id: province.id });
}
i want to query all province with the tpsReports limited to 12 on every province. or maybe is there any other ways to do that approach?
0 Replies
No replies yetBe the first to reply to this messageJoin
Want results from more Discord servers?
Add your server