import { neon } from "@neondatabase/serverless";
import { drizzle } from "drizzle-orm/neon-http";
import { users } from "@/db/schema";
const accessToken = <access_token>;
const createAuthenticatedDb = () => {
const connectionString = <authenticated_db_connection_string>;
if (!connectionString) {
throw new Error("Database connection string is not set");
}
const sql = neon(connectionString);
return drizzle(sql);
};
const db = createAuthenticatedDb();
const run = async () => {
const result = await db.$withAuth(accessToken).select().from(users);
console.log(result);
};
import { neon } from "@neondatabase/serverless";
import { drizzle } from "drizzle-orm/neon-http";
import { users } from "@/db/schema";
const accessToken = <access_token>;
const createAuthenticatedDb = () => {
const connectionString = <authenticated_db_connection_string>;
if (!connectionString) {
throw new Error("Database connection string is not set");
}
const sql = neon(connectionString);
return drizzle(sql);
};
const db = createAuthenticatedDb();
const run = async () => {
const result = await db.$withAuth(accessToken).select().from(users);
console.log(result);
};