Module

x/pg_mem/interfaces.ts>IMemoryDb

An in memory postgres DB instance for your unit tests
Go to Latest
interface IMemoryDb
import { type IMemoryDb } from "https://dotland.deno.dev/x/pg_mem@2.6.3/interfaces.ts";

Properties

readonly
adapters: LibAdapters

Adapters to create wrappers of this db compatible with known libraries

readonly
public: ISchema

The default 'public' schema

Methods

getSchema(db?: string | null): ISchema

Get an existing schema

createSchema(name: string): ISchema

Create a schema in this database

getTable<T = any>(table: string): IMemoryTable<T>

Get a table to inspect it (in the public schema... this is a shortcut for db.public.getTable())

getTable<T = any>(table: string, nullIfNotFound?: boolean): IMemoryTable<T> | null
on(event: "query", handler: (query: string) => any): ISubscription

Subscribe to a global event

on(event: GlobalEvent, handler: () => any): ISubscription
on(event: GlobalEvent, handler: () => any): ISubscription
on(event: TableEvent, handler: (table: string) => any): ISubscription

Subscribe to an event on all tables

backup(): IBackup

Creates a restore point. 👉 This operation is O(1) (instantaneous, even with millions of records).

registerExtension(name: string, install: (schema: ISchema) => void): this

Registers an extension (that can be installed using the 'create extension' statement)

registerLanguage(languageName: string, compiler: LanguageCompiler): this

Registers a new language, usable in 'DO' blocks, or in 'CREATE FUNCTION' blocks