sqlite-ulid icon indicating copy to clipboard operation
sqlite-ulid copied to clipboard

Publish types for npm package.

Open deadcoder0904 opened this issue 2 years ago • 5 comments

I asked ChatGPT for types & it gave this:

declare module "sqlite-ulid" {
  export function getLoadablePath(): string;
}

Can you publish this? I'll use a global.d.ts in the meantime :)

And thanks for the project. Does it add ulid to id automatically?

deadcoder0904 avatar Jan 31 '24 12:01 deadcoder0904

Bdw, I tried starting the application & I got this error:

Error: Loadble extension for sqlite-ulid not found. Was the sqlite-ulid-windows-x64 package installed? Avoid using the --no-optional flag, as the optional dependencies for sqlite-ulid are required.

Do I need to install https://www.npmjs.com/package/sqlite-ulid-windows-x64 too?

Windows instructions unclear.

deadcoder0904 avatar Jan 31 '24 12:01 deadcoder0904

Okay, I think installing sqlite-ulid-windows-x64 solved it for seed command.

But when I run my application, I get this error:

⨯ TypeError [ERR_INVALID_ARG_TYPE]: The "path" argument must be of type string or an instance of URL. Received an instance of URL

Idk what to do now?

deadcoder0904 avatar Jan 31 '24 12:01 deadcoder0904

I tried .toString() method too but that didn't work.

Here's my code:

import { drizzle } from 'drizzle-orm/better-sqlite3'
import sqlite from 'better-sqlite3'
import * as sqlite_ulid from 'sqlite-ulid'

const client = sqlite(process.env.DATABASE_PATH)
client.pragma('journal_mode = WAL') // see https://github.com/WiseLibs/better-sqlite3/blob/master/docs/performance.md
client.loadExtension(sqlite_ulid.getLoadablePath())

export const db = drizzle(client)

I'm using it for this project on sqlite branch if you wanna clone & test -> https://github.com/deadcoder0904/next-13-lucia-auth-drizzle-turso-sqlite-magic-link/tree/sqlite

Lmk if there are any solutions? I can't find anything on this online.

deadcoder0904 avatar Jan 31 '24 12:01 deadcoder0904

Alright, I'll use ulidx npm package as an alternative for now with drizzle's $defaultFn like:

import { ulid } from "ulid";

export const users = sqliteTable("users", {
  id: text("id")
    .primaryKey()
    .$defaultFn(() => ulid()),
});

Courtesy of https://www.answeroverflow.com/m/1191758386711253133

deadcoder0904 avatar Jan 31 '24 12:01 deadcoder0904

I'm having the same issue in node and bun No types are included in sqlite-ulid

nephix avatar Aug 25 '24 05:08 nephix