© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
Drizzle TeamDT
Drizzle Team•2y ago•
6 replies
Baran

Type error when inserting

Aim
insert row to
contactInformationTable
contactInformationTable


My attempt
// schema.ts
import { blob, integer, sqliteTable, text } from 'drizzle-orm/sqlite-core';
import { generateId } from 'lucia';

export const userTable = sqliteTable('user', {
  id: text('id')
    .notNull()
    .primaryKey()
    .$default(() => generateId(15)),
  hashedPassword: text('hashed_password').notNull(),
});

export const contactInformationTable = sqliteTable('contact_information', {
  userId: text('user_id')
    .notNull()
    .unique()
    .references(() => userTable.id),
  firstName: text('first_name'),
});
// schema.ts
import { blob, integer, sqliteTable, text } from 'drizzle-orm/sqlite-core';
import { generateId } from 'lucia';

export const userTable = sqliteTable('user', {
  id: text('id')
    .notNull()
    .primaryKey()
    .$default(() => generateId(15)),
  hashedPassword: text('hashed_password').notNull(),
});

export const contactInformationTable = sqliteTable('contact_information', {
  userId: text('user_id')
    .notNull()
    .unique()
    .references(() => userTable.id),
  firstName: text('first_name'),
});

// serverFunction.ts
    await db
      .insert(contactInformationTable)
      .values({
        userId: user.id,
        firstName,
      })
// serverFunction.ts
    await db
      .insert(contactInformationTable)
      .values({
        userId: user.id,
        firstName,
      })


// package.json
"drizzle-orm": "^0.31.0",
"drizzle-kit": "^0.21.4",
// package.json
"drizzle-orm": "^0.31.0",
"drizzle-kit": "^0.21.4",
Drizzle TeamJoin
The official Discord for all Drizzle related projects, such as Drizzle ORM, Drizzle Kit, Drizzle Studio and more!
11,879Members
Resources

Similar Threads

Was this page helpful?
Recent Announcements

Similar Threads

Type Error when inserting into table
Drizzle TeamDTDrizzle Team / help
16mo ago
Type error inserting 'new Date()' into 'time' type schema.
Drizzle TeamDTDrizzle Team / help
3y ago
Issue when inserting
Drizzle TeamDTDrizzle Team / help
3y ago
Inserting into columns of type Enum
Drizzle TeamDTDrizzle Team / help
3y ago