Mohammed Anas
Mohammed Anas
Explore posts from servers
TtRPC
Created by Mohammed Anas on 1/9/2024 in #❓-help
client side Validation with ZOD
will trpc validate input on the client before sending it to the server ?
12 replies
TtRPC
Created by Mohammed Anas on 1/3/2024 in #❓-help
How is the Client Generated with just the types
I'm trying to build a trpc like app for building restful apis with sveltekit. In trpc sveltekit only the type is passed to the client fucntion and how is the client object typically created with just the type?
2 replies
TtRPC
Created by Mohammed Anas on 11/18/2023 in #❓-help
How does trpc typing work
I'm curious to know how trpc generates type without a code gen step , i am trying to acheive something like this
export class API {
private schema:z.ZodSchema = z.undefined()
input<T>(inp:z.ZodSchema<T>){
this.schema = inp
return this
}
get(input:z.infer<typeof this.schema>){
console.log(("ok"));
}
}
const api = new API()
api.input(z.object({
name:z.string()
}))

// I need a way to typically extract this {name:string} type without a codegen step
export class API {
private schema:z.ZodSchema = z.undefined()
input<T>(inp:z.ZodSchema<T>){
this.schema = inp
return this
}
get(input:z.infer<typeof this.schema>){
console.log(("ok"));
}
}
const api = new API()
api.input(z.object({
name:z.string()
}))

// I need a way to typically extract this {name:string} type without a codegen step
8 replies
DTDrizzle Team
Created by Mohammed Anas on 9/28/2023 in #help
Drizzle kit schema migration with mysql ; Rerunning the entire schema
I use mysql2 as my database and when i run my migrate script "migrate": "drizzle-kit push:mysql --config drizzle.config.ts" this works fine but when i rerun my migrate script i get this error
Error: Duplicate key name 'company_id'
at PromiseConnection.query (/home/anasmohammed361/vs/fund-master/node_modules/.pnpm/[email protected]/node_modules/drizzle-kit/index.cjs:35481:26)
at Command.<anonymous> (/home/anasmohammed361/vs/fund-master/node_modules/.pnpm/[email protected]/node_modules/drizzle-kit/index.cjs:53292:33)
at process.processTicksAndRejections (node:internal/process/task_queues:95:5) {
code: 'ER_DUP_KEYNAME',
errno: 1061,
sql: 'CREATE INDEX `company_id` ON `company` (`id`);',
sqlState: '42000',
sqlMessage: "Duplicate key name 'company_id'"
Error: Duplicate key name 'company_id'
at PromiseConnection.query (/home/anasmohammed361/vs/fund-master/node_modules/.pnpm/[email protected]/node_modules/drizzle-kit/index.cjs:35481:26)
at Command.<anonymous> (/home/anasmohammed361/vs/fund-master/node_modules/.pnpm/[email protected]/node_modules/drizzle-kit/index.cjs:53292:33)
at process.processTicksAndRejections (node:internal/process/task_queues:95:5) {
code: 'ER_DUP_KEYNAME',
errno: 1061,
sql: 'CREATE INDEX `company_id` ON `company` (`id`);',
sqlState: '42000',
sqlMessage: "Duplicate key name 'company_id'"
3 replies
DTDrizzle Team
Created by Mohammed Anas on 8/18/2023 in #help
How do i insert a Enum value into a table
Basic Setup
export const userRoles = pgEnum('role', ['admin', 'maintainer']);
export const users = pgTable("userAuth", {
id: text("id").notNull().primaryKey(),
name: text("name"),
email: text("email").notNull().unique(),
emailVerified: timestamp("emailVerified"),
image: text("image"),
role:userRoles('role').default('maintainer').notNull()
});

export const userRoles = pgEnum('role', ['admin', 'maintainer']);
export const users = pgTable("userAuth", {
id: text("id").notNull().primaryKey(),
name: text("name"),
email: text("email").notNull().unique(),
emailVerified: timestamp("emailVerified"),
image: text("image"),
role:userRoles('role').default('maintainer').notNull()
});

await db.insert(users).values({
email:"a@a",
role:userRoles.enumValues[0],
id:"123"
})
await db.insert(users).values({
email:"a@a",
role:userRoles.enumValues[0],
id:"123"
})
I get this error
BadRequestException: ERROR: column "role" is of type role but expression is of type character varying
Hint: You will need to rewrite or cast the expression.
Position: 125; SQLState: 42804
BadRequestException: ERROR: column "role" is of type role but expression is of type character varying
Hint: You will need to rewrite or cast the expression.
Position: 125; SQLState: 42804
14 replies
DTDrizzle Team
Created by Mohammed Anas on 8/10/2023 in #help
Aws Rds with drizzle
My Schema on Aws Rds is not updating , once i update my schema and generate the schema , i am not getting any errors but still the migrations seems to fail , when i try to insert into that table BadRequestException: ERROR: relation "fuc" does not exist Position: 13; SQLState: 42P01 I get this
22 replies
DTDrizzle Team
Created by Mohammed Anas on 8/9/2023 in #help
Error with drizzle-kit generate:pg
Transforming const to the configured target environment ("es5") is not supported yet
7 replies