Skip to content

Commit

Permalink
feat(driver-adapters): remove TypeScript from "pglite-node-basic" (#5231
Browse files Browse the repository at this point in the history
)
  • Loading branch information
jkomyno authored Jul 16, 2024
1 parent 4801dcc commit c38ecbd
Show file tree
Hide file tree
Showing 5 changed files with 45 additions and 530 deletions.
Original file line number Diff line number Diff line change
@@ -1,14 +1,18 @@
// @ts-check
import { Prisma, PrismaClient } from '@prisma/client'
import { PGlite } from '@electric-sql/pglite'
import { readFile } from 'fs/promises'
import { PrismaPGlite } from 'pglite-prisma-adapter'
import { readFile } from 'fs/promises'

const client = new PGlite() // in memory
//const client = new PGlite("foo.database") // persist to disk
const adapter = new PrismaPGlite(client)
const prisma = new PrismaClient({ adapter })

async function applyMigrations(client: any) {
/**
* @param {PGlite} client
*/
async function applyMigrations(client) {
// read prisma/migration.sql file and apply it
console.log('Applying migrations...')
const migration = await readFile('./prisma/migration.sql', 'utf8')
Expand All @@ -17,7 +21,10 @@ async function applyMigrations(client: any) {
}

export async function handler() {
const getResult = async (prisma: any) => ({
/**
* @param {PrismaClient | Prisma.TransactionClient} prisma
*/
const getResult = async (prisma) => ({
prismaVersion: Prisma.prismaVersion.client,
deleteMany: await prisma.user.deleteMany().then(() => ({ count: 0 })),
create: await prisma.user.create({
Expand Down Expand Up @@ -114,7 +121,6 @@ export async function handler() {
age: true,
},
})
// @ts-expect-error
.then(({ _avg }) => ({ age: Math.trunc(_avg?.age ?? 0) })),
groupBy: await prisma.user.groupBy({
by: ['age'],
Expand Down
6 changes: 0 additions & 6 deletions driver-adapters/pglite-node-basic/jest.config.ts

This file was deleted.

5 changes: 1 addition & 4 deletions driver-adapters/pglite-node-basic/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,11 @@
"@types/jest": "29.5.12",
"jest": "29.7.0",
"prisma": "5.17.0-dev.38",
"ts-jest": "29.2.2",
"typescript": "^5.4.5"
},
"dependencies": {
"@electric-sql/pglite": "^0.1.5",
"@prisma/client": "5.17.0-dev.38",
"pglite-prisma-adapter": "^0.2.0",
"ts-node": "10.9.2",
"tsx": "^4.11.2"
"pglite-prisma-adapter": "^0.2.0"
}
}
Loading

0 comments on commit c38ecbd

Please sign in to comment.