Hey <!everyone> :v: :prisma-cool: We just release...
# prisma-whats-new
a
Hey <!everyone> โœŒ๏ธ prisma cool We just released Prisma
3.10.0
prisma rainbow We are working towards a stable release of MongoDB and are shipping lots of improvements. All the major features and breaking changes in this release therefore only apply to the MongoDB connector. Take a closer look if you are using the Preview of MongoDB as some of the changes are breaking. ๐Ÿ“„ Embedded documents support is now in preview Weโ€™re super excited to announce that Prisma version
3.10.0
supports reading and modifying embedded documents. Embedded documents will provide access to a new
type
keyword in your Prisma schema that you can use to define composite types.
Copy code
datasource db {
  provider = "mongodb"
  url      = env("DATABASE_URL")
}

generator client {
  provider        = "prisma-client-js"
  previewFeatures = ["mongoDb"]
}

model Product {
  id     String  @id @default(auto()) @map("_id") @db.ObjectId
  name   String
  photos Photo[]
}

type Photo {
  height Int
  width  Int
  url    String
}
Given the schema above, you can now read and write to the embedded
photos
array:
Copy code
// Create a new product with an embedded list of photos
const product = await prisma.product.create({
  data: {
    name: "Forest Runners",
    price: 59.99,
    // Create an embedded list of photos in the product
    photos: [
      { height: 100, width: 200, url: "1.jpg" },
      { height: 300, width: 400, url: "2.jpg" },
    ],
  },
})
You can read further in our documentation. Feel free to open an issue if you run into anything, and weโ€™ll give you a hand! ๐Ÿ” Introspection of embedded documents is now enabled by default We added Preview support for embedded documents in version
3.4.0
and are now activating it for all users. Running
prisma db pull
against your MongoDB database will generate
type
definitions within your Prisma schema. When introspecting your database, you can switch off the depth with
-composite-type-depth=0
, or limit it with, for example,
--composite-type-depth=2
. Feel free to drop your feedback on the feature on GitHub. ๐Ÿšจ
@default(dbgenerated())
is now replaced with
@default(auto())
The original purpose of
dbgenerated
is to support SQL expressions Prisma doesnโ€™t understand yet. However, MongoDB doesnโ€™t have a concept of default value expressions like SQL does. We took this opportunity to simplify handling the default values in MongoDB. ๐Ÿšจ Many-to-Many relations now require a
references
argument
Prisma version
3.10.0
now enforces all arguments in a MongoDB many-to-many relation. This means a
@relation
attribute must define
fields
and
references
arguments on both sides. The
fields
argument must point to a scalar field in the same model, and this scalar field must be an array. The
references
arguments must point to a scalar field in the opposite model, and it must be a singular type of the same base type as the referencing array on the other side.
Copy code
model Post {
  id           String   @id @map("_id") @default(auto()) @db.ObjectId
  category_ids String[] @db.ObjectId
  categories   Category[]      @relation(fields: [category_ids], references: [id])
}
    
model Category {
  id       String   @id @map("_id") @default(auto()) @db.ObjectId
  post_ids String[] @db.ObjectId
  posts    Post[] @relation(fields: [post_ids], references: [id])
}
๐Ÿšจ
db.Array(ObjectId)
is now updated to
@db.ObjectId
The original purpose of
dbgenerated
is to support SQL expressions Prisma doesnโ€™t understand yet. However, MongoDB doesnโ€™t have a concept of default value expressions like SQL does. We took this opportunity to simplify how we handle the default values in MongoDB. ๐Ÿ“š 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 it 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 This week, @Austin and I will discuss the latest release and other news from the Prisma ecosystem in a

livestream on YouTubeโ–พ

this Thursday at 5 pm Berlin | 8 am San Francisco.
๐Ÿ‡ง๐Ÿ‡ด 1
prisma rainbow 34
๐Ÿ‡ง๐Ÿ‡ท 6
๐Ÿ’ฅ 4
catjam 6
๐Ÿ•บ๐Ÿฝ 1
๐ŸŒถ๏ธ 2
๐Ÿคฉ 5
๐Ÿš€ 29
๐ŸŽค 7
๐ŸŽ‰ 19
โœจ 3
๐Ÿ”ฅ 6
๐Ÿฆœ 4
๐Ÿ“ฃ 4
prisma cool 6
๐Ÿ‡ช๐Ÿ‡บ 2
๐Ÿ‡ฎ๐Ÿ‡ณ 5
๐Ÿ‡ณ๐Ÿ‡ฑ 2
๐Ÿ‡ฐ๐Ÿ‡ท 9
๐Ÿ•บ 2
๐Ÿ‡ต๐Ÿ‡ฑ 10
mongodb 15
๐Ÿ‡ท๐Ÿ‡ด 8
prisma green 21
๐Ÿ™Œ๐Ÿฝ 1
fast parrot 20
โญ 3
๐Ÿ˜Ž 2
๐Ÿณ๏ธโ€๐ŸŒˆ 2
๐Ÿ‡ฆ๐Ÿ‡ฒ 2
๐Ÿ‡ณ๐Ÿ‡ด 2
๐Ÿ‘ 1
๐Ÿ‡ฎ๐Ÿ‡ฑ 3
๐Ÿ‡ฉ๐Ÿ‡ช 3
๐Ÿ‡ฎ๐Ÿ‡ถ 2
๐Ÿ‡ป๐Ÿ‡ณ 1
๐Ÿ‡ช๐Ÿ‡ธ 1
๐Ÿ‡จ๐Ÿ‡ด 1
โค๏ธ 7
๐Ÿ‡ง๐Ÿ‡ช 2
prisma yellow 2
๐Ÿ‡ณ๐Ÿ‡ฌ 4
๐Ÿ‡ฟ๐Ÿ‡ฆ 2
๐Ÿ‡ฏ๐Ÿ‡ต 4
typescript 1
๐Ÿ‡บ๐Ÿ‡ฟ 1
๐Ÿ™Œ 6
๐Ÿ‡ธ๐Ÿ‡ฆ 1
๐Ÿ‡ช๐Ÿ‡น 1
๐Ÿ‡ช๐Ÿ‡ฌ 1
๐Ÿ‡ฉ๐Ÿ‡ฏ 2