kbemaster
kbemaster
Explore posts from servers
DTDrizzle Team
Created by kbemaster on 2/26/2024 in #help
Shouldn't the fields related to the Query API be of type <T | undefined> ?
When getting related fields using the findFirst or findMany methods, the appended fields that I bring with "with" should not be of type <T | undefined> so that in case nothing is found it is safe.
6 replies
DTDrizzle Team
Created by kbemaster on 2/22/2024 in #help
Guaranteed undefined for Nested Results? Type Mismatch in Query API
No description
4 replies
TTCTheo's Typesafe Cult
Created by kbemaster on 1/22/2024 in #questions
Is there any benefit to putting the db connection in the context versus having it as an global var?
Can I do this?
export const challengesRouter = router({
getChallengeById: privateProcedure
.input(z.string().uuid())
.query(async ({ input }) => {
const challenge = await db.query.challengeTable.findFirst({
where: (columns, { eq }) => eq(columns.sectionId, input),
columns: {
id: true,
sectionId: true,
},
});
return challenge;
}),
});
export const challengesRouter = router({
getChallengeById: privateProcedure
.input(z.string().uuid())
.query(async ({ input }) => {
const challenge = await db.query.challengeTable.findFirst({
where: (columns, { eq }) => eq(columns.sectionId, input),
columns: {
id: true,
sectionId: true,
},
});
return challenge;
}),
});
or in this way i have a benefit?
export const challengesRouter = router({
getChallengeById: privateProcedure
.input(z.string().uuid())
.query(async ({ input, ctx }) => {
const challenge = await ctx.db.query.challengeTable.findFirst({
where: (columns, { eq }) => eq(columns.sectionId, input),
columns: {
id: true,
sectionId: true,
},
});
return challenge;
}),
});
export const challengesRouter = router({
getChallengeById: privateProcedure
.input(z.string().uuid())
.query(async ({ input, ctx }) => {
const challenge = await ctx.db.query.challengeTable.findFirst({
where: (columns, { eq }) => eq(columns.sectionId, input),
columns: {
id: true,
sectionId: true,
},
});
return challenge;
}),
});
6 replies
TtRPC
Created by kbemaster on 1/22/2024 in #❓-help
Is there any benefit to putting the db connection in the context versus having it as an global var?
Can I do this?
export const challengesRouter = router({
getChallengeById: privateProcedure
.input(z.string().uuid())
.query(async ({ input }) => {
const challenge = await db.query.challengeTable.findFirst({
where: (columns, { eq }) => eq(columns.sectionId, input),
columns: {
id: true,
sectionId: true,
},
});
return challenge;
}),
});
export const challengesRouter = router({
getChallengeById: privateProcedure
.input(z.string().uuid())
.query(async ({ input }) => {
const challenge = await db.query.challengeTable.findFirst({
where: (columns, { eq }) => eq(columns.sectionId, input),
columns: {
id: true,
sectionId: true,
},
});
return challenge;
}),
});
or in this way i have a benefit?
export const challengesRouter = router({
getChallengeById: privateProcedure
.input(z.string().uuid())
.query(async ({ input, ctx }) => {
const challenge = await ctx.db.query.challengeTable.findFirst({
where: (columns, { eq }) => eq(columns.sectionId, input),
columns: {
id: true,
sectionId: true,
},
});
return challenge;
}),
});
export const challengesRouter = router({
getChallengeById: privateProcedure
.input(z.string().uuid())
.query(async ({ input, ctx }) => {
const challenge = await ctx.db.query.challengeTable.findFirst({
where: (columns, { eq }) => eq(columns.sectionId, input),
columns: {
id: true,
sectionId: true,
},
});
return challenge;
}),
});
7 replies