PackageTrack

npm · #3659 most downloaded on npm

@prisma/client

7.10.0prisma/prisma

Prisma Client is an auto-generated, type-safe and modern JavaScript/TypeScript ORM for Node.js that's tailored to your data. Supports PostgreSQL, CockroachDB, MySQL, MariaDB, SQL Server, SQLite & MongoDB databases.

Release timeline

10653 releases since 2020
20202026

One column per quarter.

Releases

  1. 5.4.29 Oct 2023
    Release notes

    Today, we are issuing the 5.4.2 patch release.

    Fix in Prisma Client

    Open source →
  2. 5.4.2-dev.19 Oct 2023pre-release

    Nothing published for this version

  3. 5.4.14 Oct 2023
    Release notes

    Today, we are issuing the 5.4.1 patch release.

    Fix in Prisma Client

    Fix in @prisma/adapter-planetscale

    Open source →
  4. 5.4.1-dev.24 Oct 2023pre-release

    Nothing published for this version

  5. 5.4.1-dev.14 Oct 2023pre-release

    Nothing published for this version

  6. 5.4.04 Oct 2023
    Release notes

    🌟 Help us spread the word about Prisma by starring the repo or tweeting about the release. 🌟

    Highlights

    Preview support for PlanetScale and Neon serverless database drivers

    We’re excited to announce Preview support for the Neon and PlanetScale serverless database drivers. The PlanetScale and Neon serverless database drivers allow Prisma to connect to your database using protocols besides TCP — HTTP (PlanetScale) or WebSockets (Neon).

    To get started with the serverless database drivers, first enable the driverAdapters Preview feature flag in your Prisma schema:

    // schema.prisma
    generator client {
      provider        = "prisma-client-js"
      previewFeatures = ["driverAdapters"]
    }
    

    Next, to set up Prisma Client to use the serverless database drivers:

    PlanetScale

    Install the Prisma adapter for PlanetScale and PlanetScale serverless database driver, and undici:

    npm install @prisma/adapter-planetscale @planetscale/database undici
    

    Prisma ORM supports Node 16 and up. In Node 18 and up, undici is not needed.

    Ensure you update the host value in your connection string to aws.connect.psdb.cloud. You can learn more about this here.

    DATABASE_URL='mysql://johndoe:[email protected]/clear_nightsky?sslaccept=strict'
    

    Update your Prisma Client instance to use the PlanetScale database driver:

    // Import required dependencies
    import { connect } from '@planetscale/database';
    import { PrismaPlanetScale } from '@prisma/adapter-planetscale';
    import { PrismaClient } from '@prisma/client';
    import { fetch as undiciFetch } from 'undici';
    
    // Initialize Prisma Client with the PlanetScale serverless database driver
    const connection = connect({ url: connectionString, fetch: undiciFetch });
    const adapter = new PrismaPlanetScale(connection);
    const prisma = new PrismaClient({ adapter });
    

    PlanetScale Driver in 5.7.0 and later

    In Prisma 5.7.0, usage of the PlanetScale driver adapter changed to the following:

    // For Prisma 5.7.0 and later
    // Import required dependencies
    import { Client } from '@planetscale/database';
    import { PrismaPlanetScale } from '@prisma/adapter-planetscale';
    import { PrismaClient } from '@prisma/client';
    
    // Initialize Prisma Client with the PlanetScale serverless database driver
    const client = new Client({ url: process.env.DATABASE_URL });
    const adapter = new PrismaPlanetScale(client);
    const prisma = new PrismaClient({ adapter });
    

    Neon

    Install the Prisma adapter for Neon, Neon serverless database driver and undici (WebSockets):

    npm install @prisma/adapter-neon @neondatabase/serverless undici
    

    Update your Prisma Client instance to use the Neon serverless database driver:

    // Import required dependencies
    import { Pool, neonConfig } from '@neondatabase/serverless';
    import { PrismaNeon } from '@prisma/adapter-neon';
    import { PrismaClient } from '@prisma/client';
    import { WebSocket } from 'undici'
    
    neonConfig.webSocketConstructor = WebSocket;
    
    // Initialize Prisma Client with the Neon serverless database driver
    const pool = new Pool({ connectionString: process.env.DATABASE_URL });
    const adapter = new PrismaNeon(pool);
    const prisma = new PrismaClient({ adapter });
    

    Let us know your feedback about the Neon or Planetscale serverless database drivers in the linked GitHub discussions. Create a bug report if you run into any issues.

    Early Access support for Turso

    Turso is an edge-hosted, distributed database that's based on libSQL, an open-source and open-contribution fork of SQLite, enabling you to bring data closer to your application and minimize query latency.

    Since support for Turso is in Early Access, there may be some rough edges which we’re still working on it to improve the API and overall support. Additionally, it is behind the driverAdapters Preview feature flag. Enable it to get started using Turso in your project:

    // schema.prisma
    generator client {
      provider        = "prisma-client-js"
      previewFeatures = ["driverAdapters"]
    }
    

    Next, install the Prisma Client adapter for Turso and the libSQL database client

    npm install @prisma/adapter-libsql @libsql/client
    

    Update your Prisma Client instance:

    // Import required dependencies
    import { PrismaClient } from '@prisma/client'
    import { PrismaLibSQL } from '@prisma/adapter-libsql'
    import { createClient } from '@libsql/client'
    
    // Create a new instance of the libSQL database client
    const libsql = createClient({
      // @ts-expect-error
      url: process.env.TURSO_DATABASE_URL,
      authToken: process.env.TURSO_AUTH_TOKEN 
    })
    
    // Create a Prisma "adapter" for libSQL
    const adapter = new PrismaLibSQL(libsql)
    // Pass the adapter option to the Prisma Client instance
    const prisma = new PrismaClient({ adapter })
    

    You can learn more on how to use Prisma together with Turso in the announcement blog post.

    Try it out! Let us know what you think and create a bug report if you run into any issues.

    Query performance improvements

    In our continued efforts to make Prisma Client faster, we identified and improved the performance of different types of queries.

    Relation filters improvements

    We made the following improvements to relation filters:

    • Removed an unnecessary INNER JOIN used in relation filter queries (Big thank you to @KhooHaoYit for helping out)
    • Use of LEFT JOIN's for to-one relations. Previously, Prisma made use of sub-queries to fetch data.

    Example Prisma Client query

    prisma.comment.findMany({
      where: {
        post: {
          author: {
            name: "John"
          }
        }
      }
    })
    

    Before 5.4.0

    SELECT
      "Comment"."id"
    FROM
      "Comment"
    WHERE
      ("Comment"."id") IN (
        SELECT
          "t0"."id"
        FROM
          "Comment" AS "t0"
          INNER JOIN "Post" AS "j0" ON ("j0"."id") = ("t0"."postId")
        WHERE
          (
            ("j0"."id") IN (
              SELECT
                "t1"."id"
              FROM
                "Post" AS "t1"
                INNER JOIN "User" AS "j1" ON ("j1"."id") = ("t1"."userId")
              WHERE
                (
                  "j1"."name" = $ 1
                  AND "t1"."id" IS NOT NULL
                )
            )
            AND "t0"."id" IS NOT NULL
          )
      );
    

    After 5.4.0

    SELECT
      "Comment"."id"
    FROM
      "Comment"
      LEFT JOIN "Post" AS "j1" ON ("j1"."id") = ("Comment"."postId")
      LEFT JOIN "User" AS "j2" ON ("j2"."id") = ("j1"."userId")
    WHERE
      (
        "j2"."name" = $ 1
        AND ("j2"."id" IS NOT NULL)
        AND ("j1"."id" IS NOT NULL)
      );
    

    If you’re interested in more details on the relation query filter improvements, you can take a look at this pull request.

    Enum improvements on PostgreSQL and CockroachDB

    Previously, when an enum value was used in a query, our Postgres driver would make additional queries to resolve the enum types that were used.

    In this release, we’re making improvements by casting enums to TEXT to avoid the additional roundtrips when resolving the types.

    This change should have the most impact if you’re using pgBouncer or if you’re running Prisma in a serverless environment, where our Postgres driver can’t cache enum types information.

    Prisma schema

    model User {
      id   Int  @id @default(cuid())
      role Role
    }
    
    enum Role {
      User
      Admin
    }
    

    Prisma Client query

    await prisma.user.findMany({ 
      where: {
        role: "Admin"
      }
    })
    

    Before 5.4.0

    -- Internal driver query
    SELECT t.typname, t.typtype, t.typelem, r.rngsubtype, t.typbasetype, n.nspname, t.typrelid FROM pg_catalog.pg_type t LEFT OUTER JOIN pg_catalog.pg_range r ON r.rngtypid = t.oid INNER JOIN pg_catalog.pg_namespace n ON t.typnamespace = n.oid WHERE t.oid = $1;
    
    -- Internal driver query
    SELECT enumlabel FROM pg_catalog.pg_enum WHERE enumtypid = $1 ORDER BY enumsortorder;
    
    -- Prisma Client query
    SELECT id, role FROM "User" WHERE role = $1;
    

    After 5.4.0

    -- Prisma Client query
    SELECT id, role::text FROM "User" WHERE role = CAST($1::text AS "Role);
    

    Bulk delete improvements

    We optimized the deleteMany operation by:

    • Removing all SELECT queries used to fetch data that would be used as input for the DELETE operation. In some cases, this also improves index usage.
    • Removing the transaction previously used as it’s now a single atomic operation.

    Prisma Client query

    
    await prisma.post.deleteMany({
      where: {
        id: {
          gt: 1,
          lt: 10,
        }
      }
    })
    

    Before 5.4.0

    BEGIN
    SELECT id FROM "Post" WHERE id > 1 AND id < 10;
    SELECT id FROM "Post" WHERE id > 1 AND id < 10 AND id IN (<...select ids>);
    DELETE FROM "Post" WHERE id IN (<...select ids>) AND id > 1 AND id < 10;
    COMMIT
    

    After 5.4.0

    DELETE FROM "Post" WHERE id > 1 AND id < 10;
    

    Upsert improvements

    We improved the upsert operation (non-native database upsert) by removing a redundant SELECT query:

    Prisma Client query

    await prisma.user.upsert({
      where: { email: "[email protected]" },
      create: { email: "[email protected]", firstName: "John" },
      update: { firstName: "Johnny" },
    })
    

    Before 5.4.0

    SELECT `User`.`id` FROM `User` WHERE `User`.`email` = ?;
    SELECT `User`.`id` FROM `User` WHERE `User`.`email` = ?;
    UPDATE `prisma`.`User` SET `firstName` = ? WHERE `prisma`.`User`.`id` IN (?) AND `prisma`.`User`.`email` = ?;
    SELECT `User`.`id` FROM `User` WHERE `User`.`id` = ?;
    

    After 5.4.0

    SELECT `User`.`id` FROM `User` WHERE `User`.`email` = ?;
    UPDATE `prisma`.`User` SET `firstName` = ? WHERE `prisma`.`User`.`id` IN (?) AND `prisma`.`User`.`email` = ?;
    SELECT `User`.`id` FROM `User` WHERE `User`.`id` = ?;
    

    Fixes and improvements

    Prisma Client

    Language tools (e.g. VS Code)

    Prisma Engines

    Credits

    Huge thanks to @onichandame, @fqazi, @KhooHaoYit, @alencardc, @Oreilles, @christianledgard, @skyzh, @alula, @michaelpoellath, @RobertCraigie, @icanipa, @jiashengguo, @stephenwade, @darthmaim, @ludralph, @Gerschtli, @andyjy for helping!

    💼 We're hiring!

    If you're interested in joining our growing team to help empower developers to build data-intensive applications, Prisma is the place for you.

    We're currently hiring for the following roles:

    Feel free to read the job descriptions and apply using the links provided.

    Open source →
  7. 5.4.0-integration-libsql-adapter.725 Sept 2023pre-release

    Nothing published for this version

  8. 5.4.0-integration-libsql-adapter.625 Sept 2023pre-release

    Nothing published for this version

  9. 5.4.0-integration-libsql-adapter.521 Sept 2023pre-release

    Nothing published for this version

  10. 5.4.0-integration-libsql-adapter.420 Sept 2023pre-release

    Nothing published for this version

  11. 5.4.0-integration-libsql-adapter.320 Sept 2023pre-release

    Nothing published for this version

  12. 5.4.0-integration-libsql-adapter.119 Sept 2023pre-release

    Nothing published for this version

  13. 5.4.0-integration-fix-type-leaks.93 Oct 2023pre-release

    Nothing published for this version

  14. 5.4.0-integration-fix-type-leaks.83 Oct 2023pre-release

    Nothing published for this version

  15. 5.4.0-integration-fix-type-leaks.729 Sept 2023pre-release

    Nothing published for this version

  16. 5.4.0-integration-fix-type-leaks.629 Sept 2023pre-release

    Nothing published for this version

  17. 5.4.0-integration-fix-type-leaks.529 Sept 2023pre-release

    Nothing published for this version

  18. 5.4.0-integration-fix-type-leaks.422 Sept 2023pre-release

    Nothing published for this version

  19. 5.4.0-integration-fix-type-leaks.222 Sept 2023pre-release

    Nothing published for this version

  20. 5.4.0-integration-fix-type-leaks.121 Sept 2023pre-release

    Nothing published for this version

  21. 5.4.0-integration-fix-controlled-exports.118 Sept 2023pre-release

    Nothing published for this version

  22. 5.4.0-integration-fix-client-extension-mock.163 Oct 2023pre-release

    Nothing published for this version

  23. 5.4.0-integration-fix-client-extension-mock.153 Oct 2023pre-release

    Nothing published for this version

  24. 5.4.0-integration-fix-client-extension-mock.143 Oct 2023pre-release

    Nothing published for this version

  25. 5.4.0-integration-fix-client-extension-mock.133 Oct 2023pre-release

    Nothing published for this version

  26. 5.4.0-integration-fix-client-extension-mock.123 Oct 2023pre-release

    Nothing published for this version

  27. 5.4.0-integration-fix-client-extension-mock.113 Oct 2023pre-release

    Nothing published for this version

  28. 5.4.0-integration-fix-client-extension-mock.103 Oct 2023pre-release

    Nothing published for this version

  29. 5.4.0-integration-fix-client-extension-mock.93 Oct 2023pre-release

    Nothing published for this version

  30. 5.4.0-integration-fix-client-extension-mock.829 Sept 2023pre-release

    Nothing published for this version

  31. 5.4.0-integration-fix-client-extension-mock.728 Sept 2023pre-release

    Nothing published for this version

  32. 5.4.0-integration-fix-client-extension-mock.620 Sept 2023pre-release

    Nothing published for this version

  33. 5.4.0-integration-fix-client-extension-mock.520 Sept 2023pre-release

    Nothing published for this version

  34. 5.4.0-integration-fix-client-extension-mock.420 Sept 2023pre-release

    Nothing published for this version

  35. 5.4.0-integration-fix-client-extension-mock.319 Sept 2023pre-release

    Nothing published for this version

  36. 5.4.0-integration-fix-client-extension-mock.219 Sept 2023pre-release

    Nothing published for this version

  37. 5.4.0-integration-fix-client-extension-mock.119 Sept 2023pre-release

    Nothing published for this version

  38. 5.4.0-integration-fix-client-disable-env-adapter.24 Oct 2023pre-release

    Nothing published for this version

  39. 5.4.0-integration-fix-client-disable-env-adapter.14 Oct 2023pre-release

    Nothing published for this version

  40. 5.4.0-integration-feat-driver-adapters-in-client.919 Sept 2023pre-release

    Nothing published for this version

  41. 5.4.0-integration-feat-driver-adapters-in-client.819 Sept 2023pre-release

    Nothing published for this version

  42. 5.4.0-integration-feat-driver-adapters-in-client.715 Sept 2023pre-release

    Nothing published for this version

  43. 5.4.0-integration-feat-driver-adapters-in-client.615 Sept 2023pre-release

    Nothing published for this version

  44. 5.4.0-integration-feat-driver-adapters-in-client.515 Sept 2023pre-release

    Nothing published for this version

  45. 5.4.0-integration-feat-driver-adapters-in-client.414 Sept 2023pre-release

    Nothing published for this version

  46. 5.4.0-integration-feat-driver-adapters-in-client.314 Sept 2023pre-release

    Nothing published for this version

  47. 5.4.0-integration-feat-driver-adapters-in-client.213 Sept 2023pre-release

    Nothing published for this version

  48. 5.4.0-integration-feat-driver-adapters-in-client.113 Sept 2023pre-release

    Nothing published for this version

  49. 5.4.0-integration-engines-5-4-0-7-libsql-adapter-80b70c2ed99e6febf0f4a3832eaa12c73c53d083.119 Sept 2023pre-release

    Nothing published for this version

  50. 5.4.0-integration-engines-5-4-0-40-janpio-shadow-drop-with-force-134b510303ababf88da061a7d13b598a4b8f9c95.129 Sept 2023pre-release

    Nothing published for this version

  51. 5.4.0-integration-engines-5-4-0-24-libsql-adapter-8337c6b372b0f4eb2500403a7cf450885aee4cdc.125 Sept 2023pre-release

    Nothing published for this version

  52. 5.4.0-integration-engines-5-4-0-17-libsql-adapter-4bdd9f5982a2a7e03a9d18b798a260989a71bb16.121 Sept 2023pre-release

    Nothing published for this version

  53. 5.4.0-integration-engines-5-4-0-15-libsql-adapter-037ce403b001dacf99a1532070d6a18a3879bc65.120 Sept 2023pre-release

    Nothing published for this version

  54. 5.4.0-integration-dispose-tx.327 Sept 2023pre-release

    Nothing published for this version

  55. 5.4.0-integration-dispose-tx.227 Sept 2023pre-release

    Nothing published for this version

  56. 5.4.0-integration-dispose-tx.126 Sept 2023pre-release

    Nothing published for this version

  57. 5.4.0-dev.864 Oct 2023pre-release

    Nothing published for this version

  58. 5.4.0-dev.854 Oct 2023pre-release

    Nothing published for this version

  59. 5.4.0-dev.843 Oct 2023pre-release

    Nothing published for this version

  60. 5.4.0-dev.833 Oct 2023pre-release

    Nothing published for this version