Unable to read error message when inserting withdb.insert().values()

Hey there, i am using visual studio code and am developing with nuxt3. I am trying to insert an object but I am getting an error message that is very difficult to read. Am I doing something wrong? I have no idea what's wrong looking at this..
Martacus
Martacus195d ago
No description
Martacus
Martacus195d ago
Okay so my bad, I had wrong types for the createdAt and updatedAt. The error is very complicated and my eyes just couldnt really focus. In the schema I added .defaultNow() to them. Will updatedAt be updated on every edit to the row?

export const users = pgTable("user", {
id: uuid('id').defaultRandom().primaryKey(),
name: text("name").notNull(),
email: text("email").notNull(),
password: text("password").notNull(),
createdAt: timestamp("created_at").notNull().defaultNow(),
updatedAt: timestamp("updated_at").notNull().defaultNow()
});

export const users = pgTable("user", {
id: uuid('id').defaultRandom().primaryKey(),
name: text("name").notNull(),
email: text("email").notNull(),
password: text("password").notNull(),
createdAt: timestamp("created_at").notNull().defaultNow(),
updatedAt: timestamp("updated_at").notNull().defaultNow()
});
Angelelz
Angelelz195d ago
No, defaultNot is only for insertion Pg doesn't have an on update clause I think people use triggers for stuff like this
Martacus
Martacus195d ago
tyty
Want results from more Discord servers?
Add your server
More Posts
how to add new driver to drizzle?what is the procedure of adding a new driver to drizzle orm?`drizzle-kit --custom` is not giving me a blank migration fileI'm doing the following: ```sh drizzle-kit generate:pg --custom ``` But it's not giving me a blankNo id returned (mysql2)``` async function create(data: NewBusiness) { return client.insert(business).values(data) } ``` Studio when using Turso `Error: Cannot find module 'better-sqlite3'`Error when trying to start Studio and push `Error: Cannot find module 'better-sqlite3'`[BUG]: React Hook Form doesn't submit when using drizzle-zod to create schemes to use in zodResolverWhen using `drizzle-zod` to generate schemas from database schemas and using them in the `useForm` rAppending SQL chunks to a queryHey everyone, I'm trying to see if there is a way where I can build SQL queries conditionally (basedPostgresjs with Neon giving connnection refusal errorI am unable to connect to my neon database. I tried using `postgresjs` and the `neon serverless` drierror: column "id" cannot be cast automatically to type uuidim using drizzle, and this is my schema: ```typescript export const tags = pgTable("tags", { id: uinArray() using sql`` operator in JS and PostgresHey, how do I use sql operator with arrays in JS? ```javascript const array = [1,2,3]; const sqlQuerUnable to infer relationI have the following tables and relations: ```javascript export const platforms = pgTable('platformsmigrate with node-postgresI had migration working well with postgresjs but need to switch to node-postgres for other reasons. .all() API not availableI have two tables that I want to join, and I want to join them to get the following result: ```javasGet subquery columns in a way similar to `getTableColumns`Keeping track manually of all subquery fields can quickly become annoying, and I'm looking for a simSlow queries with relationshipsHi all, I recently moved from querying 4 tables concurrently, to using drizzle relations and using dCannot read properties of undefined (reading 'referencedTable')const result = await db.query.ads.findMany({ with: { owner: trueHow do I load sqlite extensions for drizzle-kit?In my code, when I want to use drizzle I am doing the following: ```ts const sqlite = new SQLite3(en