prisma-mysql-explain
TypeScript icon, indicating that this package has built-in type declarations

0.3.0 • Public • Published

prisma-mysql-explain

Execute mysql explain for Prisma

WARNING

This library is for development environments.

Don't use production environment.

usage

import { createExplain } from "prisma-mysql-explain"

const createPrisma = () => {
  // Need query event log
  const prisma = new PrismaClient({
    log: [{ level: "query", emit: "event" }]
  })

  const prismaExplain = creatExplainQuery(prisma, {cacheType: "params"})

  prisma.$on("query", async (event) => {
    const result = await prismaExplain.explain(event)
    if (!result) {
      return
    }
    console.log(result)
  })
  
  return prisma
}

API

createExplain(prisma: PrismaClient, option: Option?)

Option

  • cacheType
    • query(default) - Cache with query
    • param - Cache with query and params
    • none - Disable cahce

Return

  • explain: (event: Prisma.QueryEvent) => ExplainResult[]

Package Sidebar

Install

npm i prisma-mysql-explain

Weekly Downloads

76

Version

0.3.0

License

MIT

Unpacked Size

79.1 kB

Total Files

29

Last publish

Collaborators

  • terrierscript