Braveheart
Braveheart
Explore posts from servers
DDeno
Created by Braveheart on 7/25/2023 in #help
Prisma and deno
getting this
error: could not find package '.prisma' from referrer 'file:///Users/nikos/WebstormProjects/vanillajs-patterns/backend/node_modules/.deno/@[email protected]/node_modules/@prisma/client/index.js'.
error: could not find package '.prisma' from referrer 'file:///Users/nikos/WebstormProjects/vanillajs-patterns/backend/node_modules/.deno/@[email protected]/node_modules/@prisma/client/index.js'.
from this
import { Prisma, PrismaClient } from '@prisma/client';

import { config } from 'https://deno.land/[email protected]/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',
passwordHash: await bcrypt.hash('password', 10),
emailVerified: true,
customFields: {
test: 'field',
},
},
{
name: 'Nikos',
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/[email protected]/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',
passwordHash: await bcrypt.hash('password', 10),
emailVerified: true,
customFields: {
test: 'field',
},
},
{
name: 'Nikos',
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
22 replies