Skip to content
Discussion options

You must be logged in to vote

I think that the issue is that BetterSQLite3 is a synchronous sqlite library.
You don't need to await anything, just use the all, run, get and values methods available in all the query builders.

Please see the changes I made to your index.ts file:

import Database from "better-sqlite3";
import { drizzle } from "drizzle-orm/better-sqlite3";
import { users } from "./schema";

const sqlite = new Database("./sqlite.db");
const db = drizzle(sqlite);

function seed(database: typeof db) {
  const { changes } = database
    .insert(users)
    .values([
      {
        fullName: "User_" + Date.now().toString(),
      },
    ]).run()

  const insertedUser = database.select().from(users).get();

  co…

Replies: 5 comments 9 replies

Comment options

You must be logged in to vote
1 reply
@john-prutton
Comment options

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
4 replies
@john-prutton
Comment options

@Angelelz
Comment options

Angelelz Nov 1, 2023
Collaborator

Answer selected by john-prutton
@john-prutton
Comment options

@Angelelz
Comment options

Angelelz Nov 1, 2023
Collaborator

Comment options

You must be logged in to vote
4 replies
@Angelelz
Comment options

Angelelz Nov 5, 2023
Collaborator

@nonua
Comment options

@Angelelz
Comment options

Angelelz Nov 6, 2023
Collaborator

@nonua
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
6 participants