https://github.com/terrierscript/prisma-mysql-explain
https://github.com/terrierscript/prisma-mysql-explain
Last synced: 3 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/terrierscript/prisma-mysql-explain
- Owner: terrierscript
- License: mit
- Created: 2022-08-30T14:31:04.000Z (over 3 years ago)
- Default Branch: main
- Last Pushed: 2022-09-02T13:43:40.000Z (over 3 years ago)
- Last Synced: 2025-01-18T14:28:14.117Z (about 1 year ago)
- Language: TypeScript
- Size: 174 KB
- Stars: 4
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# prisma-mysql-explain
Execute mysql explain for [Prisma](https://www.prisma.io/)
### WARNING
This library is for development environments.
**Don't use production environment.**
## usage
```ts
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[]`