[solved] database.insert is not a function

Hey friends, I'm trying to setup drizzle with mysql but can not insert data :/
import { drizzle } from "drizzle-orm/mysql2";
import mysql from "mysql2/promise"

const conn = await mysql.createConnection({
host: opts.host,
user: opts.username,
password: opts.password,
ssl: { rejectUnauthorized: true }
})
const db = drizzle(conn,
{
schema,
mode: "default"
},
);

console.log("connected to db", Object.keys(db))
// connected to db [ "dialect", "session", "mode", "query", "_" ]
import { drizzle } from "drizzle-orm/mysql2";
import mysql from "mysql2/promise"

const conn = await mysql.createConnection({
host: opts.host,
user: opts.username,
password: opts.password,
ssl: { rejectUnauthorized: true }
})
const db = drizzle(conn,
{
schema,
mode: "default"
},
);

console.log("connected to db", Object.keys(db))
// connected to db [ "dialect", "session", "mode", "query", "_" ]
and then in my app it crashes:
await database.insert(schema.workspaces).values(unkeyWorkspace);
^
TypeError: database.insert is not a function. (In 'database.insert(schema.workspaces)', 'database.insert' is undefined)
await database.insert(schema.workspaces).values(unkeyWorkspace);
^
TypeError: database.insert is not a function. (In 'database.insert(schema.workspaces)', 'database.insert' is undefined)
Has anyone encountered this too?
1 Reply
chronark
chronarkOP13mo ago
connecting via planetscale driver works, but I'm trying to find a way to test against a local mysql instance in our CI ok case closed, I'm too stupid to use await
Want results from more Discord servers?
Add your server