Module

x/nessie/mod.ts>AbstractClient

A modular Deno library for PostgreSQL, MySQL, MariaDB and SQLite migrations
Latest
class AbstractClient
Abstract
import { AbstractClient } from "https://dotland.deno.dev/x/nessie@2.0.11/mod.ts";

The abstract client which handles most of the logic related to database communication.

Constructors

new
AbstractClient(options: AbstractClientOptions<Client>)

Properties

protected
logger: LoggerFn
protected
readonly
QUERY_GET_ALL
protected
readonly
QUERY_GET_LATEST
protected
QUERY_MIGRATION_DELETE: QueryWithString
protected
QUERY_MIGRATION_INSERT: QueryWithString
client: Client
optional
dialect: DBDialects | string

The current dialect, given by the Client e.g. pg, mysql, sqlite

migrationFiles: FileEntryT[]

Migration files read from the migration folders

seedFiles: FileEntryT[]

Seed files read from the seed folders

Methods

private
_migrationHandler(
file: FileEntryT,
queryHandler: QueryHandler,
isDown?,
)

Handles migration files.

private
_sliceMigrationFiles(queryResult: string | undefined): void

Filters and sort files in ascending order.

protected
_migrate(
latestMigration: string | undefined,
queryHandler: QueryHandler,
)

Runs the up method on all available migrations after filtering and sorting.

protected
_parseAmount(
maxAmount?,
isMigration?,
): number
protected
splitAndTrimQueries(query: string)

Splits and trims queries.

_rollback(
allMigrations: string[] | undefined,
queryHandler: QueryHandler,
)

Runs the down method on defined number of migrations after retrieving them from the DB.

_seed(matcher?)

Runs the run method on seed files. Filters on the matcher.

abstract
close(): Promise<void>

Closes the db connection

abstract
getAll(): Promise<string[]>

Gets all entries from the migration table

abstract
migrate(amount: AmountMigrateT): Promise<void>

Handles the migration

abstract
prepare(): Promise<void>

Prepares the db connection

abstract
query(query: QueryT): Promise<any>

Universal wrapper for db query execution

abstract
rollback(amount: AmountRollbackT): Promise<void>

Handles the rollback

abstract
seed(matcher?: string): Promise<void>

Handles the seeding

Sets the logger for the client. Given by the State.

abstract
updateTimestamps(): Promise<void>

Updates timestamp format

import AbstractClient
import { AbstractClient } from "https://dotland.deno.dev/x/nessie@2.0.11/mod.ts";