Quantcast
Channel: Active questions tagged svelte - Stack Overflow
Viewing all articles
Browse latest Browse all 1541

Sveltekit + prisma db + multiple databases

$
0
0

I wrote a Web App which uses its own DB. For simplicity, I chose prisma db for the DB stuff. However, everything works fine until I reached the point where I need to connect to a second database with existing tables. I found this GitHub post, so I changed my code like:

prisma/schema.prisma > prisma/schema1.prisma:

generator client {  provider = "prisma-client-js"  output   = "./generated/client1"}datasource db {  provider = "sqlserver"  url      = env("DATABASE_URL")}

and added prisma/schema2.prisma:

generator client {  provider = "prisma-client-js"  output   = "./generated/client2"}datasource db2 {  provider = "sqlserver"  url      = env("DATABASE_PYTHON_URL")}

The pull command creates the schema2.prisma models successfully, and the generate command generates the prisma/generated/client1 and client2 folders.

My db.js:

// import { PrismaClient } from '@prisma/client';import { PrismaClient1 } from './prisma/generated/client1'import { PrismaClient2 } from './prisma/generated/client2'// export const prisma = new PrismaClient();export const client1 = new PrismaClient1();export const client2 = new PrismaClient2();

After starting the dev Server again, I faced this error:

ReferenceError: exports is not definedat ./prisma/generated/client1:2:23at instantiateModule (file:///C:/Users/user/Documents/Svelte/test/node_modules/vite/dist/node/chunks/dep-ca21228b.js:52420:15

I tried to delete the node_modules and reinstall everything but facing still the same error.


Viewing all articles
Browse latest Browse all 1541

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>