Add Deno support #2440
Replies: 17 comments 2 replies
-
An example using deno in the docs would be nice as well |
Beta Was this translation helpful? Give feedback.
-
The problem is that drizzle is looking for drizzle-orm in package json?
|
Beta Was this translation helpful? Give feedback.
-
Yeah im trying this out and coming across issues where drizzle-orm is depending on postgres drivers that just don't exist.
it tries to pull in postgres but can't find it:
however I don't really know where this could be and the replacements i've looked at don't seem to work properly - though this may be related to an unfamiliarity with import map scopes. this is with an import_map.json that includes: "drizzle-orm": "npm:drizzle-orm", |
Beta Was this translation helpful? Give feedback.
-
seems it that was resolved with #505 . to consolidate: use the below import map:
and use the below to create a db:
im not sure if there is a better way to pull pool in from pg, but for some reason im getting errors saying its not found. |
Beta Was this translation helpful? Give feedback.
-
hopefully we'll have something better for an ESM import+ drizzle kit |
Beta Was this translation helpful? Give feedback.
-
Also found another set of working imports for drizzle-orm which works with better typing: import_map:
code:
besides the point though, I would also like to see drizzle kit work too with deno as the only other alternative i have is by running node for drizzle-kit and deno for actual queries/modifications |
Beta Was this translation helpful? Give feedback.
-
If drizzle-orm will include this import-map, import should than work with ESM? |
Beta Was this translation helpful? Give feedback.
-
not exactly. I was intending that you could use that as an import map within your code to resolve the module. Actually it seems that when just using the following it properly imports the types and code. import maps
|
Beta Was this translation helpful? Give feedback.
-
Yeah, Drizzle ORM works, the only thing we need compatibility-wise is to get |
Beta Was this translation helpful? Give feedback.
-
UPDATE: I just tried out Drizzle for the first time today with Deno and it looks like it's working (as long as
Would it be possible to improve typings somehow so that TypeScript wouldn't complain when |
Beta Was this translation helpful? Give feedback.
-
@dankochetov what's the recommended workaround ATM? Deno does have some support for package.json, and Node for ESM. So, I'm already on deno and deno-deploy but new to drizzle and not sure what's the best hack in your opinion |
Beta Was this translation helpful? Give feedback.
-
Anyone got any sort of guide for this? I get this error: Uncaught Error: Could not locate the bindings file. Tried: from this import { sqliteTable, text, integer } from 'drizzle-orm/sqlite-core';
import { drizzle } from 'drizzle-orm/better-sqlite3';
import Database from 'better-sqlite3';
const users = sqliteTable('users', {
id: integer('id').primaryKey(), // 'id' is the column name
fullName: text('full_name'),
});
const sqlite = new Database('sqlite.db');
const db = drizzle(sqlite);
const allUsers = db.select().from(users).all(); |
Beta Was this translation helpful? Give feedback.
-
I've moved to |
Beta Was this translation helpful? Give feedback.
-
it's time to support Deno guys, Deno will pump hard next year. |
Beta Was this translation helpful? Give feedback.
-
deno now has a lot of npm & node API compat, package.json support and even node_modules dir support features, maybe it can just work. |
Beta Was this translation helpful? Give feedback.
-
Currently, the best way to use with deno IMO is npm install -g drizzle-orm drizzle-kit drizzle-orm: {
//...
"imports": {
"drizzle-orm": "npm:[email protected]"
},
"tasks":{
"drizzle-introspect": "export $(cat .env | xargs) && drizzle-kit introspect:pg --connectionString=$DB_CONNECTION_STRING --driver=pg --out=src/clients/pg/.drizzle"
}
} that's it. it should work. this is my client.ts import { drizzle } from "drizzle-orm/postgres-js"
import postgres from "npm:postgres"
import * as schema from "./.drizzle/schema.ts"
const connectionString = Deno.env.get("DB_CONNECTION_STRING")
const client = postgres(connectionString)
export const db = drizzle(client, { schema })
export * from "./.drizzle/schema.ts"
export * as orm from "drizzle-orm" |
Beta Was this translation helpful? Give feedback.
-
Deno has now released version 2.0, and it also supports all Node.js APIs. However, can deno support go further? deno has a sqlite driver based on deno ffi, and I hope drizzle can support it natively. Here is the driver: |
Beta Was this translation helpful? Give feedback.
-
Currently, the ORM part should work fine with Deno since it's runtime-agnostic, but the migrator won't work since it relies on Node API.
Beta Was this translation helpful? Give feedback.
All reactions