Skip to main content
Module

x/denodb_esgi/mod.ts>Database

MySQL, SQLite, MariaDB, PostgreSQL and MongoDB ORM for Deno
Latest
class Database
import { Database } from "https://deno.land/x/denodb_esgi@1.0.15.1/mod.ts";

Database client which interacts with an external database instance.

Constructors

new
Database(databaseOptionsOrDialect: DatabaseOptions, connectionOptions:
| PostgresOptions
| SQLite3Options
| MySQLOptions
| MongoDBOptions
)

Initialize database given a dialect and options.

const db = new Database("sqlite3", {
  filepath: "./db.sqlite"
});

const db = new Database({
  dialect: "sqlite3",
  debug: true
}, { ... });

Properties

private
_connector: Connector
private
_debug: boolean
private
_dialect: DatabaseDialect
private
_models: ModelSchema[]
private
_queryBuilder: QueryBuilder

Methods

_computeModelFieldMatchings(
table: string,
fields: ModelFields,
withTimestamps: boolean,
): { toClient: FieldMatchingTable; toDatabase: FieldMatchingTable; }

Compute field matchings tables for model usage.

Close the current database connection.

Get the database dialect.

Test database connection.

query(query: QueryDescription): Promise<any>

Pass on any query to the database.

await db.query("SELECT * FROM `flights`");
sync(options?: SyncOptions)

Create the given models in the current database.

await db.sync({ drop: true });