KHRM
KHRM
Explore posts from servers
DTDrizzle Team
Created by fermentfan on 7/30/2023 in #help
Mocking Drizzle instance
i ended up just testing with another database instead of mocking it
22 replies
DTDrizzle Team
Created by KHRM on 5/5/2024 in #help
Auth.js (next-auth) with Drizzle Provider Typescript
Ahh that's not too bad at least for my case I'm just setting it to themselves basically, at least it's more consistent then me overriding the functions
4 replies
DTDrizzle Team
Created by KHRM on 5/5/2024 in #help
Auth.js (next-auth) with Drizzle Provider Typescript
currently I am overriding the specific functions of the adapter as needed (although i should probably override all of them to keep it consistent)
adapter: {
...DrizzleAdapter(db, ),
/** here users points to my users table not the one from inside the adapter **/
async createUser(data: AdapterUser) {
const hasDefaultId = getTableColumns(users)["id"]["hasDefault"];

return db
.insert(users)
.values(hasDefaultId ? data : { ...data, id: crypto.randomUUID() })
.returning()
.get();
},
async getUserByAccount(
account: Pick<AdapterAccount, "provider" | "providerAccountId">,
) {
const result = await db
.select({
account: accounts,
user: users,
})
.from(accounts)
.innerJoin(users, eq(accounts.userId, users.id))
.where(
and(
eq(accounts.provider, account.provider),
eq(accounts.providerAccountId, account.providerAccountId),
),
)
.get();

return result?.user ?? null;
},
},
adapter: {
...DrizzleAdapter(db, ),
/** here users points to my users table not the one from inside the adapter **/
async createUser(data: AdapterUser) {
const hasDefaultId = getTableColumns(users)["id"]["hasDefault"];

return db
.insert(users)
.values(hasDefaultId ? data : { ...data, id: crypto.randomUUID() })
.returning()
.get();
},
async getUserByAccount(
account: Pick<AdapterAccount, "provider" | "providerAccountId">,
) {
const result = await db
.select({
account: accounts,
user: users,
})
.from(accounts)
.innerJoin(users, eq(accounts.userId, users.id))
.where(
and(
eq(accounts.provider, account.provider),
eq(accounts.providerAccountId, account.providerAccountId),
),
)
.get();

return result?.user ?? null;
},
},
4 replies
DTDrizzle Team
Created by fermentfan on 7/30/2023 in #help
Mocking Drizzle instance
No description
22 replies