Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Publish types for npm package. #9

Open
deadcoder0904 opened this issue Jan 31, 2024 · 5 comments
Open

Publish types for npm package. #9

deadcoder0904 opened this issue Jan 31, 2024 · 5 comments

Comments

@deadcoder0904
Copy link

deadcoder0904 commented Jan 31, 2024

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
Copy link
Author

deadcoder0904 commented Jan 31, 2024

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
Copy link
Author

deadcoder0904 commented Jan 31, 2024

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
Copy link
Author

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
Copy link
Author

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

@nephix
Copy link

nephix commented Aug 25, 2024

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants