Skip to content

Commit

Permalink
chore: add comment about closing PrismaClient and Connector (#353)
Browse files Browse the repository at this point in the history
  • Loading branch information
jackwotherspoon authored May 28, 2024
1 parent dc7e0d0 commit d6d653e
Show file tree
Hide file tree
Showing 6 changed files with 18 additions and 0 deletions.
3 changes: 3 additions & 0 deletions examples/prisma/mysql/connect.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,9 @@ async function connect({instanceConnectionName, user, database}) {
const datasourceUrl = `mysql://${user}@localhost/${database}?socket=${path}`;
const prisma = new PrismaClient({datasourceUrl});

// Return PrismaClient and close() function. Call close() when you are
// done using the PrismaClient to ensure client gracefully disconnects and
// local Unix socket file created by the Connector is deleted.
return {
prisma,
async close() {
Expand Down
3 changes: 3 additions & 0 deletions examples/prisma/mysql/connect.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,9 @@ export async function connect({instanceConnectionName, user, database}) {
const datasourceUrl = `mysql://${user}@localhost/${database}?socket=${path}`;
const prisma = new PrismaClient({datasourceUrl});

// Return PrismaClient and close() function. Call close() when you are
// done using the PrismaClient to ensure client gracefully disconnects and
// local Unix socket file created by the Connector is deleted.
return {
prisma,
async close() {
Expand Down
3 changes: 3 additions & 0 deletions examples/prisma/mysql/connect.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,9 @@ export async function connect({instanceConnectionName, user, database}) {
const datasourceUrl = `mysql://${user}@localhost/${database}?socket=${path}`;
const prisma = new PrismaClient({datasourceUrl});

// Return PrismaClient and close() function. Call close() when you are
// done using the PrismaClient to ensure client gracefully disconnects and
// local Unix socket file created by the Connector is deleted.
return {
prisma,
async close() {
Expand Down
3 changes: 3 additions & 0 deletions examples/prisma/postgresql/connect.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,9 @@ async function connect({instanceConnectionName, user, database}) {
const datasourceUrl = `postgresql://${user}@localhost/${database}?host=${process.cwd()}`;
const prisma = new PrismaClient({datasourceUrl});

// Return PrismaClient and close() function. Call close() when you are
// done using the PrismaClient to ensure client gracefully disconnects and
// local Unix socket file created by the Connector is deleted.
return {
prisma,
async close() {
Expand Down
3 changes: 3 additions & 0 deletions examples/prisma/postgresql/connect.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,9 @@ export async function connect({instanceConnectionName, user, database}) {
const datasourceUrl = `postgresql://${user}@localhost/${database}?host=${process.cwd()}`;
const prisma = new PrismaClient({datasourceUrl});

// Return PrismaClient and close() function. Call close() when you are
// done using the PrismaClient to ensure client gracefully disconnects and
// local Unix socket file created by the Connector is deleted.
return {
prisma,
async close() {
Expand Down
3 changes: 3 additions & 0 deletions examples/prisma/postgresql/connect.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,9 @@ export async function connect({instanceConnectionName, user, database}) {
const datasourceUrl = `postgresql://${user}@localhost/${database}?host=${process.cwd()}`;
const prisma = new PrismaClient({datasourceUrl});

// Return PrismaClient and close() function. Call close() when you are
// done using the PrismaClient to ensure client gracefully disconnects and
// local Unix socket file created by the Connector is deleted.
return {
prisma,
async close() {
Expand Down

0 comments on commit d6d653e

Please sign in to comment.