All skills
prisma avatar

/prisma-mongodb-upgrade

@1864519 official
by prismaprisma/skills68 stars
7

Decision and migration guide for Prisma ORM MongoDB projects on v6, which have no upgrade path to v7. Use when a MongoDB project asks about upgrading Prisma, when "upgrade to prisma 7" comes up in a project with provider = "mongodb", or when evaluating a move to Prisma 8. Triggers on "upgrade prisma mongodb", "prisma 7 mongodb", "mongodb prisma migration", "prisma 8 mongodb".

Use this Skill: https://skilld.dev/gh/prisma/skills/prisma-mongodb-upgrade

This session only. Nothing lands on disk.

referencesclient-api-mapping.md

≈1k tokens on demand. Your agent reads this file only when SKILL.md points to it.

client-api-mapping

How v6 Prisma Client calls map to Prisma 8's Mongo client — names map, parity does not.

Priority

CRITICAL

Why It Matters

The v6 and Prisma 8 client APIs look superficially similar, but none of the v6 MongoDB raw methods exist under their old names, aggregation moved to a different lane entirely, and transactions go through the driver rather than a Prisma method. Assuming parity produces code that does not compile — or, in the transactions case, code that silently loses atomicity.

The mapping

v6 call Prisma 8 equivalent Notes
prisma.user.findMany(...) db.orm.users.where({ ... }).all() Chained API; collection-name keys (see schema-contract-mapping.md)
prisma.user.findFirst(...) db.orm.users.where({ ... }).first() .where(...) takes a plain equality object, not { equals: ... }
create / update / upsert / delete Same names on db.orm.<collection> Every mutation except create needs a .where(...) first
updateMany / deleteMany updateAll / deleteAll
prisma.user.aggregate(...), groupBy(...) No ORM equivalent. Build a plan with db.query.from(...).group(...).build() and run it with (await db.runtime()).query(plan) Group totals come from acc in @prisma/orm-mongo/query-builder
<model>.findRaw(...), <model>.aggregateRaw(...) (v6 docs) db.raw.collection('<name>').aggregate([...]).build(), or db.query.rawCommand(...) Run the plan with (await db.runtime()).query(plan)
$runCommandRaw(...) (v6 docs) No Prisma equivalent. Create a MongoClient, pass it to the mongo(...) binding as mongoClient, and call mongoClient.db(...).command(...) db.raw is collection-scoped; database-level commands go through the driver
$transaction(...) — works on v6 with a replica set (v6 docs) No Prisma method yet. Use mongodb driver sessions (client.startSession() / session.withTransaction(...)) on a replica set Pass { session } to every operation; an operation without it runs outside the transaction
$connect / $disconnect Connects lazily on first use; db.close() disconnects

ObjectId filters in the pipeline builder: .match((f) => f.authorId.eq(authorId)) sends the id as a plain string and matches nothing. Filter ObjectId fields through the ORM client (db.orm.posts.where({ authorId })), or use db.query.rawCommand(...) with a real ObjectId.

Bad

// Assuming v6 names exist in Prisma 8:
await db.users.$runCommandRaw({ collStats: 'users' }); // no such method
await db.transaction(async (tx) => { ... });          // no such method on the MongoDB client

Good

import { acc } from '@prisma/orm-mongo/query-builder';

// Aggregation through the typed pipeline builder:
const plan = db.query
  .from('users')
  .group((f) => ({ _id: f.role, n: acc.count() }))
  .build();
const byRole = await (await db.runtime()).query(plan).toArray();

// Database-level commands through the MongoClient shared with the binding:
await mongoClient.db('my-app-db').command({ ping: 1 });

// Multi-document atomicity through a driver session:
const session = mongoClient.startSession();
try {
  await session.withTransaction(async () => {
    // ...writes, each with { session }...
  });
} finally {
  await session.endSession();
}

References

Source: SKILL.md on GitHub

No alerts1d3 checks · Risk SAFE
  • Gen Agent Trust Hub1d

    This skill is a safe instructional guide for migrating Prisma MongoDB projects from version 6 to Prisma Next. It contains technical reference materials and decision-making logic without any malicious code, obfuscation, or unauthorized data access patterns.

  • Socket1d

    No alerts

  • Snyk1d

    Risk: LOW · No issues

Signed by skilld at 1864519. This ties the file your Agent reads to that commit on GitHub. It does not review the instructions.

Last checked against GitHub 33 minutes ago.

Activeupdated 3 days ago
metadata
{
  "author": "prisma",
  "version": "0.2.0"
}

README badge

README badge for prisma/skills/prisma-mongodb-upgrade