Skip to content
Merged
Show file tree
Hide file tree
Changes from 13 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
999 changes: 999 additions & 0 deletions orm/postgis-express/bun.lock

Large diffs are not rendered by default.

14 changes: 8 additions & 6 deletions orm/postgis-express/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,14 @@
"version": "1.0.0",
"license": "MIT",
"scripts": {
"dev": "ts-node src/index.ts",
"dev": "tsx src/index.ts",
"test": "jest"
},
"dependencies": {
"@prisma/client": "6.9.0",
"@types/node": "22.18.12",
"@prisma/adapter-pg": "^6.18.0",
"@prisma/client": "^6.18.0",
"@prisma/extension-accelerate": "^2.0.2",
"dotenv": "^16.4.7",
"express": "5.1.0"
},
"devDependencies": {
Expand All @@ -19,11 +21,11 @@
"@types/supertest": "6.0.3",
"jest": "29.7.0",
"jest-environment-node": "29.7.0",
"prisma": "6.9.0",
"prisma": "^6.18.0",
"randomstring": "1.3.1",
"supertest": "7.1.4",
"ts-jest": "29.4.5",
"ts-node": "10.9.2",
"tsx": "^4.20.6",
"typescript": "5.8.2"
}
}
}
4 changes: 3 additions & 1 deletion orm/postgis-express/prisma/schema.prisma
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
generator client {
provider = "prisma-client-js"
provider = "prisma-client"
output = "./generated"
engineType = "client"
}

datasource db {
Expand Down
7 changes: 5 additions & 2 deletions orm/postgis-express/prisma/test-environment.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,10 @@ const NodeEnvironment = require('jest-environment-node').default
const randomString = require('randomstring')
const util = require('util')
const exec = util.promisify(require('child_process').exec)
const { PrismaClient } = require('@prisma/client')
const { PrismaClient } = require('./generated/client')
const { PrismaPg } = require('@prisma/adapter-pg')

const adapter = new PrismaPg({ connectionString: process.env.DB_URL })

class PrismaTestEnvironment extends NodeEnvironment {
constructor(config) {
Expand All @@ -19,7 +22,7 @@ class PrismaTestEnvironment extends NodeEnvironment {
this.databaseUrl = 'postgres://postgres:password@localhost:5432/testing'
process.env.DB_URL = this.databaseUrl
this.global.process.env.DB_URL = this.databaseUrl
this.client = new PrismaClient()
this.client = new PrismaClient({ adapter })
}

async setup() {
Expand Down
12 changes: 8 additions & 4 deletions orm/postgis-express/src/server.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
import { PrismaClient } from '@prisma/client'
import 'dotenv/config'
import { PrismaClient } from '../prisma/generated/client'
import { PrismaPg } from "@prisma/adapter-pg"
import express from 'express'

export const prisma = new PrismaClient()
const adapter = new PrismaPg({ connectionString: process.env.DB_URL })
export const prisma = new PrismaClient({ adapter })

const app = express()

app.use(express.json())
Expand Down Expand Up @@ -53,8 +57,8 @@ app.get(`/:userId/nearby-places`, async (req, res) => {
try {
const locations = await prisma.$queryRaw`
select * from "locations_near_user"(${parseInt(
userId,
)}::int, ${distance}::int)
userId,
)}::int, ${distance}::int)
`
res.json({ data: { locations } })
} catch (e) {
Expand Down
6 changes: 4 additions & 2 deletions orm/prisma-mocking-javascript/client.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
const { PrismaClient } = require('@prisma/client')
const { PrismaClient } = require('./prisma/generated/client')
const { PrismaBetterSQLite3 } = require('@prisma/adapter-better-sqlite3')

const prisma = new PrismaClient()
const adapter = new PrismaBetterSQLite3({ url: process.env.DATABASE_URL })
const prisma = new PrismaClient({ adapter });

module.exports = {
prisma,
Expand Down
9 changes: 5 additions & 4 deletions orm/prisma-mocking-javascript/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,14 @@
"license": "MIT",
"scripts": {
"test": "jest",
"dev": "node ./script.js"
"dev": "node ./client.js"
},
"dependencies": {
"@prisma/client": "6.9.0"
"@prisma/adapter-better-sqlite3": "^6.17.1",
"@prisma/client": "^6.17.1"
},
"devDependencies": {
"jest-mock-extended": "3.0.7",
"prisma": "6.9.0"
"prisma": "^6.17.1"
}
}
}
14 changes: 8 additions & 6 deletions orm/prisma-mocking-javascript/prisma/schema.prisma
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
generator client {
provider = "prisma-client-js"
provider = "prisma-client"
output = "./generated"
engineType = "client"
}

datasource db {
Expand All @@ -16,9 +18,9 @@ model User {
}

model Post {
id Int @id @default(autoincrement())
title String
content String
author User @relation(fields: [authorId], references: [id])
authorId Int
id Int @id @default(autoincrement())
title String
content String
author User @relation(fields: [authorId], references: [id])
authorId Int
}
15 changes: 8 additions & 7 deletions orm/script/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,17 @@
"name": "script",
"license": "MIT",
"scripts": {
"dev": "ts-node ./script.ts"
"dev": "tsx ./script.ts"
},
"dependencies": {
"@prisma/client": "6.9.0",
"@types/node": "22.18.12",
"@prisma/extension-accelerate": "2.0.2"
"@prisma/client": "^6.18.0",
"@prisma/extension-accelerate": "^2.0.2",
"dotenv": "^16.4.7"
},
"devDependencies": {
"prisma": "6.9.0",
"ts-node": "10.9.2",
"@types/node": "22.15.32",
"prisma": "^6.18.0",
"tsx": "^4.20.6",
"typescript": "5.8.2"
}
}
}
4 changes: 3 additions & 1 deletion orm/script/prisma/schema.prisma
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
generator client {
provider = "prisma-client-js"
provider = "prisma-client"
output = "./generated"
engineType = "client"
}

datasource db {
Expand Down
3 changes: 2 additions & 1 deletion orm/script/script.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { PrismaClient } from '@prisma/client'
import 'dotenv/config'
import { PrismaClient } from './prisma/generated/client'
import { withAccelerate } from '@prisma/extension-accelerate'

const prisma = new PrismaClient().$extends(withAccelerate())
Expand Down
9 changes: 5 additions & 4 deletions orm/starter/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,14 @@
"devDependencies": {
"@types/node": "22.18.12",
"nodemon": "3.1.10",
"prisma": "6.9.0",
"tsx": "4.20.6",
"prisma": "^6.17.1",
"tsx": "^4.20.6",
"typescript": "5.8.2"
},
"dependencies": {
"@prisma/client": "6.9.0",
"@prisma/extension-accelerate": "2.0.2"
"@prisma/client": "^6.17.1",
"@prisma/extension-accelerate": "^2.0.2",
"dotenv": "^16.4.7"
},
"prettier": {
"trailingComma": "all",
Expand Down
4 changes: 3 additions & 1 deletion orm/starter/prisma/schema.prisma
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@
// learn more about it in the docs: https://pris.ly/d/prisma-schema

generator client {
provider = "prisma-client-js"
provider = "prisma-client"
output = "./generated"
engineType = "client"
}

datasource db {
Expand Down
3 changes: 2 additions & 1 deletion orm/starter/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { PrismaClient } from '@prisma/client';
import 'dotenv/config';
import { PrismaClient } from '../prisma/generated/client';
import { withAccelerate } from '@prisma/extension-accelerate';

const prisma = new PrismaClient().$extends(withAccelerate());
Expand Down
16 changes: 8 additions & 8 deletions orm/starter/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
{
"compilerOptions": {
"target": "es6",
"module": "commonjs",
"rootDir": "./src",
"outDir": "./dist",
"target": "es6",
"module": "commonjs",
"rootDir": ".",
"outDir": "./dist",
"strict": true,
"esModuleInterop": true,
"typeRoots": [
"./node_modules/@types"
],
"forceConsistentCasingInFileNames": true,
"skipLibCheck": true
},
}
"include": [
"src"
]
}
1 change: 1 addition & 0 deletions orm/testing-express/.env.example
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
DATABASE_URL="postgresql://USER:PASSWORD@HOST:PORT/DATABASE"
Loading
Loading