Skip to main content
Module

x/pg_mem/interfaces-private.ts>ISchema

An in memory postgres DB instance for your unit tests
Latest
interface ISchema
Re-export
import { type ISchema } from "https://deno.land/x/pg_mem@2.8.1/interfaces-private.ts";

Methods

many(query: QueryOrAst): any[]

Execute a query and return many results

none(query: QueryOrAst): void

Execute a query without results

one(query: QueryOrAst): any

Execute a query with a single result

declareTable(table: Schema): IMemoryTable

Another way to create tables (equivalent to "create table" queries")

query(text: QueryOrAst): QueryResult

Execute a query

queries(text: QueryOrAst): Iterable<QueryResult>

Progressively executes a query, yielding results until the end of enumeration (or an exception)

getTable(table: string): IMemoryTable

Get a table in this db to inspect it

getTable(table: string, nullIfNotFound?: boolean): IMemoryTable | null
listTables(): Iterable<IMemoryTable>

List all tables in this schema

registerFunction(fn: FunctionDefinition, orReplace?: boolean): this

Register a function

registerOperator(fn: OperatorDefinition): this

Register a binary operator

registerEquivalentType(type: IEquivalentType): IType

Register a simple type, which is equivalent to another

getType(name: DataType): IType

Get an existing type

registerEnum(name: string, values: string[]): void

Registers an enum type on this schema

migrate(config?: MigrationParams): Promise<void>

Database migration, node-sqlite flavor ⚠ Only working when runnin nodejs !

interceptQueries(interceptor: QueryInterceptor): ISubscription

Intecept queries. If your interceptor returns an array, then the query will not be executed. The given result will be returned instead.