McPizza
McPizza
Explore posts from servers
BABetter Auth
Created by McPizza on 3/16/2025 in #bug-reports
TypeError: Cannot read properties of undefined (reading 'value') at withReturning
this is a fun error
TypeError: Cannot read properties of undefined (reading 'value')
at withReturning (/Users/omar/code/1up/node_modules/better-auth/dist/adapters/drizzle-adapter/index.cjs:169:38)
TypeError: Cannot read properties of undefined (reading 'value')
at withReturning (/Users/omar/code/1up/node_modules/better-auth/dist/adapters/drizzle-adapter/index.cjs:169:38)
with some fun code to match
withReturning: async (model, builder, data, where) => {
if (config.provider !== "mysql") {
const c = await builder.returning();
return c[0];
}
await builder.execute();
const schemaModel = getSchema(model);
const builderVal = builder.config?.values;
if (where?.length) {
const clause = convertWhereClause(where, model);
const res = await db.select().from(schemaModel).where(...clause);
return res[0];
} else if (builderVal) {
const tId = builderVal[0]?.id.value;
const res = await db.select().from(schemaModel).where(drizzleOrm.eq(schemaModel.id, tId));
return res[0];
} else if (data.id) {
const res = await db.select().from(schemaModel).where(drizzleOrm.eq(schemaModel.id, data.id));
return res[0];
}
},
withReturning: async (model, builder, data, where) => {
if (config.provider !== "mysql") {
const c = await builder.returning();
return c[0];
}
await builder.execute();
const schemaModel = getSchema(model);
const builderVal = builder.config?.values;
if (where?.length) {
const clause = convertWhereClause(where, model);
const res = await db.select().from(schemaModel).where(...clause);
return res[0];
} else if (builderVal) {
const tId = builderVal[0]?.id.value;
const res = await db.select().from(schemaModel).where(drizzleOrm.eq(schemaModel.id, tId));
return res[0];
} else if (data.id) {
const res = await db.select().from(schemaModel).where(drizzleOrm.eq(schemaModel.id, data.id));
return res[0];
}
},
18 replies
DTDrizzle Team
Created by McPizza on 9/8/2023 in #help
Subqueries with INSERT - errors
I'm trying to create an insert that uses a subquery
const sq = db.select({id: orgs.id}).from(orgs).where(eq(orgs.publicId, input.orgPublicId)).as('sq');
const insertOrgResponse = await db.insert(orgInvitations).values({
orgId: sq.id,
invitedByUserId: userId,
publicId: newPublicId,
role: input.role,
inviteToken: nanoid(),
})
const sq = db.select({id: orgs.id}).from(orgs).where(eq(orgs.publicId, input.orgPublicId)).as('sq');
const insertOrgResponse = await db.insert(orgInvitations).values({
orgId: sq.id,
invitedByUserId: userId,
publicId: newPublicId,
role: input.role,
inviteToken: nanoid(),
})
Getting type errors on orgId, seems its not detecting correct type of sq.id If I explicitly set sq.id to a number, no more errors Still need to queries though....
4 replies
DTDrizzle Team
Created by McPizza on 9/7/2023 in #help
Relationships: Self one-one & one-many
No description
9 replies
TtRPC
Created by McPizza on 9/4/2023 in #❓-help
Calling a tRPC service from another tRPC service
I have 2 services (App1 and Service2) App1 is client facing and uses trpc well But occasionally App1 backend needs to call a procedure on Service2 Should I just use the vanilla client on App1 backend and import types/context from Service2? p.s. this is not Next ecosystem
5 replies