Socket
Book a DemoInstallSign in
Socket

@prisma-extensions/read-only

Package Overview
Dependencies
Maintainers
1
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@prisma-extensions/read-only

Read Only disallows any-and-all mutation operations either for the client or specific models.

0.1.0-canary.20230204011658
latest
Source
npmnpm
Version published
Maintainers
1
Created
Source

@prisma-extensions/factory

  • @prisma-extensions/factory - Create factories
  • @prisma-extensions/msoft-delete - Enable a deletedAt field.
  • @prisma-extensions/truncate - Truncate

Challenges

  • When using model.$allModels you can't get the model the method is being acted on.
  • When using model.$allModels you can't get the types of the model the method is being acted on.

Blockers

Proposed API

  • Utilizes @prisma-extensions/truncate
const xprisma = new PrismaClient()
  .$extends(factoryExtension)
  .$extends(truncateExtension)

const UserFactory = xprisma.user.createFactory({
  firstName: "Jane",
  lastName: "Doe",
})

describe("Post", () => {
  describe("Standard" () => {
    afterEach(async () => {
      await xprisma.$truncate()
    })

    test("example", async () => {
      const user = UserFactory.build()
      const post = await PostFactory.create({
        title: "Foo",
        content: "Bar",
        author: {
          create: user,
        },
      })

      // ...
    })
  })

  // Tests should be isolated (use sparingly)
  describe("Persistent Record", () => {
    const user = UserFactory.create()

    afterAll(async () => {
      await xprisma.$truncate({ only: ["User"] })
    })

    afterEach(async () => {
      await xprisma.$truncate({ exclude: ["User"] })
    })

    test("example", async () => {
      const post = await PostFactory.create({
        title: "Foo",
        content: "Bar",
        author: {
          connect: { id: user.id },
        },
      })

      // ...
    })
  })
})

Learn more about the power of Turborepo:

  • Pipelines
  • Caching
  • Remote Caching
  • Filtering
  • Configuration Options
  • CLI Usage

Keywords

prisma

FAQs

Package last updated on 04 Feb 2023

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

About

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.

  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc

U.S. Patent No. 12,346,443 & 12,314,394. Other pending.