Yamato
Yamato
DTDrizzle Team
Created by Yamato on 9/15/2023 in #help
Issue with drizzle-zod?
Schema
export const testinArray = pgTable("testing_array", {
id: varchar("id", { length: 14 })
.primaryKey()
.$defaultFn(() => nanoid(14)),
names: text("names").array(),
});
export const testinArray = pgTable("testing_array", {
id: varchar("id", { length: 14 })
.primaryKey()
.$defaultFn(() => nanoid(14)),
names: text("names").array(),
});
const testingSchema = createInsertSchema(testinArray);
const data = { names: ["test1", "test2"] };
const newData = testingSchema.parse({ ...data });
db.insert(testinArray).values(newData).execute();
const testingSchema = createInsertSchema(testinArray);
const data = { names: ["test1", "test2"] };
const newData = testingSchema.parse({ ...data });
db.insert(testinArray).values(newData).execute();
No overload matches this call.
Overload 1 of 2, '(value: { id?: string | SQL<unknown> | Placeholder<string, any> | undefined; names?: string[] | SQL<unknown> | Placeholder<string, any> | null | undefined; }): PgInsert<...>', gave the following error.
Type '{ id?: string | undefined; names?: string | null | undefined; }' is missing the following properties from type '{ id?: string | SQL<unknown> | Placeholder<string, any> | undefined; names?: string[] | SQL<unknown> | Placeholder<string, any> | null | undefined; }[]': length, pop, push, concat, and 35 more.ts(2769)
const newData: {
id?: string | undefined;
names?: string | null | undefined;
}
No overload matches this call.
Overload 1 of 2, '(value: { id?: string | SQL<unknown> | Placeholder<string, any> | undefined; names?: string[] | SQL<unknown> | Placeholder<string, any> | null | undefined; }): PgInsert<...>', gave the following error.
Type '{ id?: string | undefined; names?: string | null | undefined; }' is missing the following properties from type '{ id?: string | SQL<unknown> | Placeholder<string, any> | undefined; names?: string[] | SQL<unknown> | Placeholder<string, any> | null | undefined; }[]': length, pop, push, concat, and 35 more.ts(2769)
const newData: {
id?: string | undefined;
names?: string | null | undefined;
}
3 replies
DTDrizzle Team
Created by Yamato on 9/11/2023 in #help
What exactly i am doing wrong.. Prepared Query
[{
"error": {
"json": {
"message": "prepared statement \"preparedConfig\" already exists",
"code": -32603,
"data": {
"code": "INTERNAL_SERVER_ERROR",
"httpStatus": 500,
"path": "config.fetch",
"zodError": null
}
}
}
}]
[{
"error": {
"json": {
"message": "prepared statement \"preparedConfig\" already exists",
"code": -32603,
"data": {
"code": "INTERNAL_SERVER_ERROR",
"httpStatus": 500,
"path": "config.fetch",
"zodError": null
}
}
}
}]
export const preparedConfig = db.query.config
.findFirst({
with: { ads: true, banners: true },
orderBy: [asc(config.config.id)],
})
.prepare("preparedConfig");

// Calling using trpc

fetch: publicProcedure.query(async ({ ctx }) => {
return await preparedConfig.execute();
}),
export const preparedConfig = db.query.config
.findFirst({
with: { ads: true, banners: true },
orderBy: [asc(config.config.id)],
})
.prepare("preparedConfig");

// Calling using trpc

fetch: publicProcedure.query(async ({ ctx }) => {
return await preparedConfig.execute();
}),
17 replies