Ahmed
Ahmed
DTDrizzle Team
Created by Ahmed on 9/30/2023 in #help
How do I configure SSL mode without using the connectionString parameter
In drizzle.config.ts I tried pushing to my database but it won't work since it requires a SSL/TLS connection. That would normally be solved using the connectionString, but I got the other parameters and I can't find a way around this. here's my config file:
import type { Config } from 'drizzle-kit';
import 'dotenv/config';

export default {
schema: './app/services/db/schema.server.ts',
driver: 'mysql2',
dbCredentials: {
host: process.env.DATABASE_HOST,
user: process.env.DATABASE_USERNAME,
password: process.env.DATABASE_PASSWORD,
database: process.env.DATABASE_NAME,
},

} satisfies Config;
import type { Config } from 'drizzle-kit';
import 'dotenv/config';

export default {
schema: './app/services/db/schema.server.ts',
driver: 'mysql2',
dbCredentials: {
host: process.env.DATABASE_HOST,
user: process.env.DATABASE_USERNAME,
password: process.env.DATABASE_PASSWORD,
database: process.env.DATABASE_NAME,
},

} satisfies Config;
2 replies
DTDrizzle Team
Created by Ahmed on 8/24/2023 in #help
cannot find package '@opentelemetry/api' in 0.28.4
I just upgraded to 0.28.4 and after I made the necessary changes for my types, I started the dev server and got this error. I'm using planetscale driver.
Error: Cannot find package '@opentelemetry/api' imported from qaimni\node_modules\.pnpm\[email protected]_@[email protected]\node_modules\drizzle-orm\planetscale-serverless\index.mjs
Error: Cannot find package '@opentelemetry/api' imported from qaimni\node_modules\.pnpm\[email protected]_@[email protected]\node_modules\drizzle-orm\planetscale-serverless\index.mjs
7 replies
DTDrizzle Team
Created by Ahmed on 8/23/2023 in #help
Chain orderBy clause problem
I have a query that filters a table based on search params
const instructors = await db
.select()
.from(DBInstructors)
.where(
and(
department ? eq(DBInstructors.department, department) : undefined,
eq(DBInstructors.section, section)
)
)
.orderBy(
sortName === 'asc' ? asc(DBInstructors.name) : desc(DBInstructors.name)
)
.orderBy(
sortRating === 'lowest'
? asc(DBInstructors.rating)
: desc(DBInstructors.rating)
)
.offset(currentPage)
.limit(10);
const instructors = await db
.select()
.from(DBInstructors)
.where(
and(
department ? eq(DBInstructors.department, department) : undefined,
eq(DBInstructors.section, section)
)
)
.orderBy(
sortName === 'asc' ? asc(DBInstructors.name) : desc(DBInstructors.name)
)
.orderBy(
sortRating === 'lowest'
? asc(DBInstructors.rating)
: desc(DBInstructors.rating)
)
.offset(currentPage)
.limit(10);
The problem is the query sorts the rows based on rating only and ignores name no matter what. Am I missing something ?
33 replies
DTDrizzle Team
Created by Ahmed on 8/15/2023 in #help
[drizzle-zod] How to make all fields of a schema derived from a table required ?
I just tried the plugin and I'm happy to move from manually creating zod schemas. However, I came into a use case where a schema must have all nullable fields in the table required. Assume we have these in users table:
const users = mysqlTable("users", {
...
speciality: varchar('speciality', { length: 255 }),
level: tinyint('level'),
...
});
const users = mysqlTable("users", {
...
speciality: varchar('speciality', { length: 255 }),
level: tinyint('level'),
...
});
The generated schema will have this type
type Schema = {
speciality: string | null | undefined,
level: number | null | undefined
}
type Schema = {
speciality: string | null | undefined,
level: number | null | undefined
}
Is there a way to make it like this ?
type Schema = {
speciality: string ,
level: number
}
type Schema = {
speciality: string ,
level: number
}
14 replies