P
Prisma•8mo ago
In&Out

Connecting prisma with mongodb issue

Hello, been following docs, used nextjs and i get this error.
4 Replies
In&Out
In&OutOP•8mo ago
"use server";

import { PrismaClient } from "@prisma/client";
const prisma = new PrismaClient();

async function Page() {
await prisma.user.create({
data: {
name: "Rich",
posts: {
create: {
title: "My first post",
body: "Lots of really interesting stuff",
slug: "my-first-post",
},
},
},
});
const allUsers = await prisma.user.findMany({
include: {
posts: true,
},
});
console.dir(allUsers, { depth: null });

return <div>Page</div>;
}

export default Page;
"use server";

import { PrismaClient } from "@prisma/client";
const prisma = new PrismaClient();

async function Page() {
await prisma.user.create({
data: {
name: "Rich",
posts: {
create: {
title: "My first post",
body: "Lots of really interesting stuff",
slug: "my-first-post",
},
},
},
});
const allUsers = await prisma.user.findMany({
include: {
posts: true,
},
});
console.dir(allUsers, { depth: null });

return <div>Page</div>;
}

export default Page;
DATABASE_URL="mongodb+srv://name:[email protected]/"
DATABASE_URL="mongodb+srv://name:[email protected]/"
This is the error i get
Raw query failed. Code: `unknown`. Message: `Kind: Command failed: Error code 8000 (AtlasError): empty database name not allowed
Raw query failed. Code: `unknown`. Message: `Kind: Command failed: Error code 8000 (AtlasError): empty database name not allowed
How do I fix this?
Nurul
Nurul•8mo ago
Hey 👋 You need to add a database name in your connection string DATABASE_URL="mongodb+srv://name:[email protected]/your_db_name"
In&Out
In&OutOP•8mo ago
My issue was I didn't make a container, fixed it, thank you
Nurul
Nurul•8mo ago
I am glad to hear that the issue is resolved now!
Want results from more Discord servers?
Add your server