D
Deno

help

Prisma and deno

BBraveheart7/25/2023
getting this
error: could not find package '.prisma' from referrer 'file:///Users/nikos/WebstormProjects/vanillajs-patterns/backend/node_modules/.deno/@prisma+client@5.0.0/node_modules/@prisma/client/index.js'.
error: could not find package '.prisma' from referrer 'file:///Users/nikos/WebstormProjects/vanillajs-patterns/backend/node_modules/.deno/@prisma+client@5.0.0/node_modules/@prisma/client/index.js'.
from this
import { Prisma, PrismaClient } from '@prisma/client';

import { config } from 'https://deno.land/std@0.163.0/dotenv/mod.ts';
import * as bcrypt from 'https://deno.land/x/bcrypt/mod.ts';

const envVars = await config();

const prisma = new PrismaClient({
datasources: {
db: {
url: envVars.DATABASE_URL,
},
},
});

const seedData: Prisma.UserCreateInput[] = [
{
name: 'Tony',
email: 'tony@test.com',
passwordHash: await bcrypt.hash('password', 10),
emailVerified: true,
customFields: {
test: 'field',
},
},
{
name: 'Nikos',
email: 'nikos@test.com',
passwordHash: await bcrypt.hash('password', 10),
emailVerified: true,
},
];

/**
* Seed the database.
*/

for (const u of seedData) {
const dinosaur = await prisma.user.create({
data: u,
});
console.log(`Created dinosaur with id: ${dinosaur.id}`);
}
console.log(`Seeding finished.`);

await prisma.$disconnect();
import { Prisma, PrismaClient } from '@prisma/client';

import { config } from 'https://deno.land/std@0.163.0/dotenv/mod.ts';
import * as bcrypt from 'https://deno.land/x/bcrypt/mod.ts';

const envVars = await config();

const prisma = new PrismaClient({
datasources: {
db: {
url: envVars.DATABASE_URL,
},
},
});

const seedData: Prisma.UserCreateInput[] = [
{
name: 'Tony',
email: 'tony@test.com',
passwordHash: await bcrypt.hash('password', 10),
emailVerified: true,
customFields: {
test: 'field',
},
},
{
name: 'Nikos',
email: 'nikos@test.com',
passwordHash: await bcrypt.hash('password', 10),
emailVerified: true,
},
];

/**
* Seed the database.
*/

for (const u of seedData) {
const dinosaur = await prisma.user.create({
data: u,
});
console.log(`Created dinosaur with id: ${dinosaur.id}`);
}
console.log(`Seeding finished.`);

await prisma.$disconnect();
following https://github.com/denoland/examples/tree/main/with-prisma
GitHub
examples/with-prisma at main · denoland/examples
A simple todo app using Deno and React. Contribute to denoland/examples development by creating an account on GitHub.
Aabi7/25/2023
I tried really hard to get Prisma working on Deno before but it seems it’s basically not worth the effort. There is an open issue on Prisma GitHub about Deno support.
DDrPotat7/25/2023
Yeah, we managed to get Prisma working on Deno but I'm not sure it was worth the effort.. or if we'll keep it @.braveheart I think the issue is that your Prisma client is being generated inside node_modules - IIRC that doesn't well with Deno (but not sure why)
DDrPotat7/25/2023
This is our folder structure - we've got everything Prisma related inside ./prisma And inside ./prisma/schema.prisma we have:
generator client {
provider = "prisma-client-js"
previewFeatures = ["deno"]
output = "./client"
}

datasource db {
provider = "mysql"
url = env("PRISMA_PROXY_DATABASE_URL")
directUrl = env("DATABASE_URL")
relationMode = "prisma"
}
generator client {
provider = "prisma-client-js"
previewFeatures = ["deno"]
output = "./client"
}

datasource db {
provider = "mysql"
url = env("PRISMA_PROXY_DATABASE_URL")
directUrl = env("DATABASE_URL")
relationMode = "prisma"
}
So the Prisma client is generated in ./prisma/client
DDrPotat7/25/2023
Then inside deno.json we've got a custom import for $prisma so we can do import { PrismaClient } from "$prisma";
"imports": {
"$prisma": "./prisma/client/deno/edge.ts",
},
"imports": {
"$prisma": "./prisma/client/deno/edge.ts",
},
We've faced a couple issues with Prisma on Deno: 1 Difficulties importing enums from Prisma client. There seems to be some typing mismatch that prevents us from importing them 2 We need to use Prisma Data Proxy to connect to the database. Otherwise, the Prisma Client generation doesn't work.
BBraveheart7/26/2023
thanks ill try that
BBraveheart7/26/2023
stuff it, im gonna use drizzle https://www.youtube.com/watch?v=Qo-RXkSwOtc
Marius Espejo
YouTube
Drizzle ORM First impressions - migrations, relations, queries!
In this video we take a quick look at the drizzle ORM to see if it's good enough to replace other options like prisma, typeorm, and Kysely. We'll create a simple application to test out creating migrations, running introspection, creating queries, and using relations. If you're looking for an orm for database queries that has very good typescrip...
BBraveheart7/26/2023
anyone used deno with it?
DDrPotat7/26/2023
Drizzle looks really interesting, thanks for sharing it We're still in early stages and not quite convinced with Prisma on Deno
DDrPotat7/26/2023
Seems like there's interest in Drizzle on Deno but not sure how well it works atm: https://github.com/drizzle-team/drizzle-orm/issues/252
GitHub
Add Deno support · Issue #252 · drizzle-team/drizzle-orm
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.
DDrPotat7/26/2023
If you get it working, can you share how?
BBraveheart7/27/2023
prisma is ESM hell yeh ill make it prob in part 7 or 8 of my videso
BBraveheart7/27/2023
Nikos Tech Downtime
YouTube
Vanilla.CSS Design System - No BlackBox Web Development - Part 6
You don't need a massive #figma based design system before you start your project. Just let your own design system evolve as you need it. It's much more extensible and customisable for your needs. #vanillajs Live demo: https://quantuminformation.github.io/vanillajs-patterns/ Full VanillaJS playlist: https://www.youtube.com/playlist?list=PLual...
BBraveheart7/27/2023
what u guys building?
DDrPotat7/27/2023
That's really cool. I'll have a look We're building an iOS app + web app for splitting bills and stuff
BBraveheart7/28/2023
im doing it in sqlite now, just vanill everything drillze wont work yet with deno the migrations part

Looking for more? Join the community!

Recommended Posts
Dates don't increment correctlywhen I run the below function with the specific date 2023-09-30, I get the result of n-1 (for any nuHi, can anyone direct me to the repo/functions where the deno/fresh project generator is held?I am looking to add functionality to this project generator but I'm not familiar enough to really fiSpeed of generatorsHow fast are JS generators when used as iterators? To be clear, I see the `for..of` loop being veryParsing HTML/XMLLately I've been researching how to write a simple HTML/XML -> JSON converter. My syntax isn't complIs it possible to import cjs module from es module, both in extension?cjs is added using `deno_core::extension`'s `js`. esm added using `deno_core::extension`'s `esm` IDeno.serve() doesn't streamhttps://gist.github.com/guest271314/39a3f93346bbc7dec5ee9fa1ff579256Deno ImportsI'm trying to use react-hook-form in an application, but bringing in the dependency results in a depWhere to store this key — and how?```ts const cryptoKey = await crypto.subtle.generateKey({ name: 'HMAC', hash: 'SHA-512' }, tTyping DateTimes```ts interface ICity { slug: string name: string description?: string createdAt: Date updBundle without exportIs it possible to have the output not having `export... ` line?LSP badly resolves relative imports between cached modulesI don't really understand this, but it looks to me like the LSP / VS Code has started resolving relaReason for "Following modules were not evaluated"What is the reason for "Following modules were not evaluated; make sure they are imported from otherdiscordav.deno.dev not working nowIm using discordav.deno.dev for get the discord profile picture from id. It was working yesterday buKV: What to return from here?```TS // Create City router.post('/cities', async (context) => { const data = await context.requLog Deno.command process outputi need to execute a command wich will keep running until stopped and log the output. i found this buUncaught TypeError: Cannot set properties of null (setting 'innerHTML')Code: var bcb = new WebSocket('wss://stream.binance.com:9443/ws/bnbusdt@trade'); bcb.onmessage = (It's hard to read that the font used in the official Deno website.On the official Deno website (deno.land), I think it difficult to distinguish between upper and lowePetition to free the module x/type from deno.landHere is the module url: https://deno.land/x/type It says it would be deleted after 30 days but has Docs on understanding how Fresh works under the hood.I want to start becoming a contributor for Fresh, I have been looking at PRs and reading documents wNode MongoDB Driver on Deno dropping connection and crashing processHeya folks. I am encountering the most recent error described in this thread https://github.com/deno