Twiser
Twiser
DTDrizzle Team
Created by Twiser on 11/11/2023 in #help
How to retrieve database credentials from drizzle.config.ts
I'm attempting to retrieve Neon database credentials dynamically from drizzle.config.ts , instead of saving them in a .env, by running drizzle-kit push. The issue, both methods I tried rely on top-level await and throw Top-level await is currently not supported with the "cjs" output format exception. 1. @aws-sdk/client-ssm example:
const { SSMClient, GetParameterCommand } = require("@aws-sdk/client-ssm");

// Create an SSM client
const ssmClient = new SSMClient();

// Define the parameter name
const parameterName = "your-parameter-name";

// Create a command to get the parameter
const command = new GetParameterCommand({ Name: parameterName, WithDecryption: true });
const { SSMClient, GetParameterCommand } = require("@aws-sdk/client-ssm");

// Create an SSM client
const ssmClient = new SSMClient();

// Define the parameter name
const parameterName = "your-parameter-name";

// Create a command to get the parameter
const command = new GetParameterCommand({ Name: parameterName, WithDecryption: true });
OR 2. SST Secrets https://docs.sst.dev/config#top-level-await Is there a way to accomplish this from within drizzle.config.ts? I'm using "drizzle-kit": "^0.20.1" and "drizzle-orm": "^0.29.0"
6 replies
DTDrizzle Team
Created by Twiser on 11/6/2023 in #help
TypeScript complaining about using a spread operator in partial select query
TypeScript complaining about me using a spread operator in partial select query. I have the following query joining data on two tables, userData and users. The query works as intended on the client side but TypeScript is complaining about me using a spread operator ...userData, (line 3) with TS2345: Argument of type [...] is not assignable to parameter of type  SelectedFields
return await db
.select({
...userData,
username: users.username,
})
.from(userData)
.leftJoin(users, eq(userData.uid, users.uid))
.orderBy(desc(userData.currentStreak))
.limit(15)
return await db
.select({
...userData,
username: users.username,
})
.from(userData)
.leftJoin(users, eq(userData.uid, users.uid))
.orderBy(desc(userData.currentStreak))
.limit(15)
I am using "drizzle-orm": "^0.28.6"
5 replies