Rich Prins
Rich Prins
Explore posts from servers
DTDrizzle Team
Created by Rich Prins on 5/22/2024 in #help
question about partial query for joins
I am running a query for 'table1', and have an inner join for the user related to 'table1' by userId, but I wanted to limit the columns for user, becuase as my query stands now, I am leaking password hashes and that's obv unsafe. Can someone point me in the right direction? It's late and I have been digging in the docs for something to alleviate this but I am trying not to resolve to using raw sql template. Here is my query as it stands:
const result = await db
.select()
.from(candidateProfileTable)
.where(eq(candidateProfileTable.id, candidateId))
.innerJoin(userTable, eq(candidateProfileTable.userId, userTable.id))
.innerJoin(disciplineTable, eq(candidateProfileTable.disciplineId, disciplineTable.id))
.innerJoin(regionTable, eq(candidateProfileTable.regionId, regionTable.id))
.leftJoin(subRegionTable, eq(regionTable.id, subRegionTable.regionId));
const result = await db
.select()
.from(candidateProfileTable)
.where(eq(candidateProfileTable.id, candidateId))
.innerJoin(userTable, eq(candidateProfileTable.userId, userTable.id))
.innerJoin(disciplineTable, eq(candidateProfileTable.disciplineId, disciplineTable.id))
.innerJoin(regionTable, eq(candidateProfileTable.regionId, regionTable.id))
.leftJoin(subRegionTable, eq(regionTable.id, subRegionTable.regionId));
3 replies