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

feat: dialect Node.js #13

Open
jlarmstrongiv opened this issue Dec 1, 2024 · 4 comments
Open

feat: dialect Node.js #13

jlarmstrongiv opened this issue Dec 1, 2024 · 4 comments

Comments

@jlarmstrongiv
Copy link

https://nodejs.org/api/sqlite.html

@jlarmstrongiv
Copy link
Author

There are two types of classes:

  • DatabaseSync
  • DatabaseAsync

DatabaseSync is currently available and is similar to better-sqlite3 and bun adapters

@subframe7536
Copy link
Owner

Yeah, that looks promising, and I found it months ago. But I decide not to implement it until the apis are stable and nobody have already implement the dialect.

@mmgoodnow
Copy link

haven't played with any migrations yet, but I took a stab here. It relies on VERY new versions of node that aren't yet typed. https://github.com/mmgoodnow/kysely-node-sqlite/blob/df086d566e9e9cefb0b6d8edc253a8cd428c8d2b/dialect/sqlite-dialect.ts

The differences are pretty minimal -

  • StatementSync.reader doesn't seem to exist - I replaced with SelectQueryNode.is which I'm not sure is right generally, but seems right enough for my purposes 🤷
  • you have to spread the params array into arguments on StatementSync methods

@subframe7536
Copy link
Owner

subframe7536 commented Dec 23, 2024

@mmgoodnow One thing that can be optimized: even if SelectQueryNode.is(query) returns false, you still need to use stmt.all() instead of stmt.run() to get the result from returning statement, like db.insertInto('table').values({data: 'test'}).returning('data')

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

3 participants