Mahmoud
07/13/2021, 3:02 PMschema.prisma
file, you’ll need to set the database provider to mongodb
. You’ll also need to add mongoDb
to the previewFeatures
property in the generator
block:
// Set the database provider to "mongodb"
datasource db {
provider = "mongodb"
url = env("DATABASE_URL")
}
// We want to generate a Prisma Client
// Since mongodb is a preview feature, we need to enable it.
generator client {
provider = "prisma-client-js"
previewFeatures = ["mongoDb"]
}
// Create our Post model which will be mapped to a collection in the database.
// The id attributes tell Prisma it's a primary key and to generate
// object ids by default when inserting posts.
model Post {
id String @id @default(dbgenerated()) @map("_id") @db.ObjectId
slug String @unique
title String
body String
}
You’ll also need to add a database connection string to your .env
file. We recommend using MongoDB Atlas to spin up a MongoDB database for free.
Learn more in our Getting Started Guide
We would love to know your feedback! If you have any comments or run into any problems we’re available in this issue. You can also browse existing issues that have the MongoDB label.
⚡️ Prisma native support for M1 Macs
This one’s for our Mac users. Prisma now runs natively on the new M1 chips. Best of all, there’s nothing to configure, it just works. Enjoy the speed bump!
📚 Learn more in the release notes
For more info and links to documentation, you can read the release notes.
🌟 Help us spread the word about Prisma 🌟
To help spread the word about Prisma, we’d very much appreciate if you would star the repo 🌟 And if you’re excited about the features in this week’s release, then help us and share your excitement on Twitter.
📰 Join us on Thursday for the “What’s new in Prisma” livestream
@ryan and @Daniel Norman will discuss the latest release and other news from the Prisma ecosystem in a on Thursday at 5pm Berlin | 8am San Francisco.