© 2026 Hedgehog Software, LLC

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

Type for schema when creating db client

import { BetterSQLite3Database, drizzle } from 'drizzle-orm/better-sqlite3'

import { drizzle as drizzleLibSQL, LibSQLDatabase } from 'drizzle-orm/libsql'

import * as schema from '~/server/database/schema'

let _db: BetterSQLite3Database | LibSQLDatabase | null = null

export const useDB = () => {
  if (!_db) {
      _db = drizzleLibSQL(
        createLibSQLClient({
          url: process.env.TURSO_DB_URL,
          authToken: process.env.TURSO_DB_TOKEN
        }),
        { schema }
      )
import { BetterSQLite3Database, drizzle } from 'drizzle-orm/better-sqlite3'

import { drizzle as drizzleLibSQL, LibSQLDatabase } from 'drizzle-orm/libsql'

import * as schema from '~/server/database/schema'

let _db: BetterSQLite3Database | LibSQLDatabase | null = null

export const useDB = () => {
  if (!_db) {
      _db = drizzleLibSQL(
        createLibSQLClient({
          url: process.env.TURSO_DB_URL,
          authToken: process.env.TURSO_DB_TOKEN
        }),
        { schema }
      )

I get the following typescript error whenever I try to include
{ schema }
{ schema }
into my db creation:

```
Type 'LibSQLDatabase<typeof import("server/database/schema")>' is not assignable to type 'BetterSQLite3Database | LibSQLDatabase<Record<string, never>> | null'.
Type 'LibSQLDatabase<typeof import("server/database/schema")>' is not assignable to type 'LibSQLDatabase<Record<string, never>>'.
The types of '
.schema' are incompatible between these types.
Type 'ExtractTablesWithRelations<typeof import("server/database/schema")> | undefined' is not assignable to type 'ExtractTablesWithRelations<Record<string, never>> | undefined'.
Type 'ExtractTablesWithRelations<typeof import("server/database/schema")>' is not assignable to type 'ExtractTablesWithRelations<Record<string, never>>'.
Property 'todos' is incompatible with index signature.
Type '{ tsName: "todos"; dbName: "todos"; columns: { id: SQLiteColumn<{ name: "id"; tableName: "todos"; dataType: "number"; columnType: "SQLiteInteger"; data: number; driverParam: number; notNull: true; hasDefault: true; enumValues: undefined; baseColumn: never; }, object>; userId: SQLiteColumn<...>; title: SQLiteColumn<....' is not assignable to type '{ tsName: string; dbName: never; columns: never; relations: Record<string, Relation<string>>; primaryKey: AnyColumn[]; }'.
Types of property 'dbName' are incompatible.
Type 'string' is not assignable to type 'never'.```
Drizzle TeamJoin
The official Discord for all Drizzle related projects, such as Drizzle ORM, Drizzle Kit, Drizzle Studio and more!
11,879Members
Resources
Was this page helpful?

Similar Threads

Recent Announcements

Similar Threads

Creating DB with schema
Drizzle TeamDTDrizzle Team / help
2y ago
PostgresError: unrecognized configuration parameter "schema" when creating client for postgres-js
Drizzle TeamDTDrizzle Team / help
3y ago
Update existing schema when introspecting db
Drizzle TeamDTDrizzle Team / help
3y ago
Type issue when creating self join
Drizzle TeamDTDrizzle Team / help
3y ago