`ctx.context.db` not available?

Why is ctx.context.db coming back as non existent? I'm using the drizzle adapter but I would like to use the kysley stuff inside the plugin so it doesn't end up only supporting drizzle. However
gatherAttributes: createAuthEndpoint(
"/abac/gatherAttributes",
{
method: "POST",
body: z.object({
subjectId: z.string(),
resourceId: z.string().optional(),
resourceType: z.string().optional(),
actionName: z.string(),
context: z.record(z.any()), // This is equivalent to Record<string, any>
}),
},
async (ctx) => {
const attributeMap = new Map<string, AttributeValue>();

const subjectAttrs = await ctx.context.db
.selectFrom("")
}
),
gatherAttributes: createAuthEndpoint(
"/abac/gatherAttributes",
{
method: "POST",
body: z.object({
subjectId: z.string(),
resourceId: z.string().optional(),
resourceType: z.string().optional(),
actionName: z.string(),
context: z.record(z.any()), // This is equivalent to Record<string, any>
}),
},
async (ctx) => {
const attributeMap = new Map<string, AttributeValue>();

const subjectAttrs = await ctx.context.db
.selectFrom("")
}
),
this is saying
Property 'db' does not exist on type '{ options: BetterAuthOptions; appName: string; baseURL: string; trustedOrigins: string[]; newSession: { session: { id: string; createdAt: Date; updatedAt: Date; ... 4 more ...; userAgent?: string | ... 1 more ... | undefined; } & Record<...>; user: { ...; } & Record<...>; } | null; ... 15 more ...; runMigrations: ()...'.ts(2339)
Property 'db' does not exist on type '{ options: BetterAuthOptions; appName: string; baseURL: string; trustedOrigins: string[]; newSession: { session: { id: string; createdAt: Date; updatedAt: Date; ... 4 more ...; userAgent?: string | ... 1 more ... | undefined; } & Record<...>; user: { ...; } & Record<...>; } | null; ... 15 more ...; runMigrations: ()...'.ts(2339)
Solution:
Appears it was removed in this PR https://github.com/better-auth/better-auth/pull/536 @bekacru Not sure if this was intended, if need be I'll make a PR to change the docs so db doesn't appear there anymore.
Jump to solution
2 Replies
Helix
HelixOP4mo ago
Actually I see it doesn't exist here https://github.com/better-auth/better-auth/blob/main/packages/better-auth/src/init.ts was there just a mistake in not removing it from the docs?
GitHub
better-auth/packages/better-auth/src/init.ts at main · better-auth...
The most comprehensive authentication framework for TypeScript - better-auth/better-auth
Solution
Helix
Helix4mo ago
Appears it was removed in this PR https://github.com/better-auth/better-auth/pull/536 @bekacru Not sure if this was intended, if need be I'll make a PR to change the docs so db doesn't appear there anymore.

Did you find this page helpful?