Home / File/ postgres-js.test.cjs — drizzle-orm Source File

postgres-js.test.cjs — drizzle-orm Source File

Architecture documentation for postgres-js.test.cjs, a javascript file in the drizzle-orm codebase. 1 imports, 0 dependents.

File javascript 1 imports

Entity Profile

Dependency Diagram

graph LR
  ba25f246_12f3_dd80_ea2e_21719662e48c["postgres-js.test.cjs"]
  8d35eaf2_a542_cfd4_fa1a_fafca0f02686["vitest"]
  ba25f246_12f3_dd80_ea2e_21719662e48c --> 8d35eaf2_a542_cfd4_fa1a_fafca0f02686
  style ba25f246_12f3_dd80_ea2e_21719662e48c fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

require('dotenv/config');
const { drizzle } = require('drizzle-orm/postgres-js');
const pg = require('postgres');
const { pg: schema } = require('./schema.cjs');
import { describe, expect } from 'vitest';

if (!process.env['PG_CONNECTION_STRING']) {
	throw new Error('PG_CONNECTION_STRING is not defined');
}

describe('postgres-js', async (it) => {
	it('drizzle(string)', async () => {
		const db = drizzle(process.env['PG_CONNECTION_STRING']);

		await db.$client.unsafe('SELECT 1;');
	});

	it('drizzle(string, config)', async () => {
		const db = drizzle(process.env['PG_CONNECTION_STRING'], {
			schema,
		});

		await db.$client.unsafe('SELECT 1;');

		expect(db.query.User).not.toStrictEqual(undefined);
	});

	it('drizzle({connection: string, ...config})', async () => {
		const db = drizzle({
			connection: process.env['PG_CONNECTION_STRING'],
			schema,
		});

		await db.$client.unsafe('SELECT 1;');

		expect(db.query.User).not.toStrictEqual(undefined);
	});

	it('drizzle({connection: params, ...config})', async () => {
		const db = drizzle({
			connection: {
				url: process.env['PG_CONNECTION_STRING'],
			},
			schema,
		});

		await db.$client.unsafe('SELECT 1;');

		expect(db.query.User).not.toStrictEqual(undefined);
	});

	it('drizzle(client)', async () => {
		const client = pg(process.env['PG_CONNECTION_STRING']);
		const db = drizzle(client);

		await db.$client.unsafe('SELECT 1;');
	});

	it('drizzle(client, config)', async () => {
		const client = pg(process.env['PG_CONNECTION_STRING']);
		const db = drizzle(client, {
			schema,
		});

		await db.$client.unsafe('SELECT 1;');

		expect(db.query.User).not.toStrictEqual(undefined);
	});

	it('drizzle({client, ...config})', async () => {
		const client = pg(process.env['PG_CONNECTION_STRING']);
		const db = drizzle({
			client,
			schema,
		});

		await db.$client.unsafe('SELECT 1;');

		expect(db.query.User).not.toStrictEqual(undefined);
	});
});

Dependencies

  • vitest

Frequently Asked Questions

What does postgres-js.test.cjs do?
postgres-js.test.cjs is a source file in the drizzle-orm codebase, written in javascript.
What does postgres-js.test.cjs depend on?
postgres-js.test.cjs imports 1 module(s): vitest.
Where is postgres-js.test.cjs in the architecture?
postgres-js.test.cjs is located at integration-tests/js-tests/driver-init/commonjs/postgres-js.test.cjs (directory: integration-tests/js-tests/driver-init/commonjs).

Analyze Your Own Codebase

Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.

Try Supermodel Free