import { Database } from "https://dotland.deno.dev/x/denodb@v1.4.0/lib/database.ts";
Database client which interacts with an external database instance.
Constructors
new
Database(dialectOptionsOrDatabaseOptionsOrConnector: DatabaseOptions, connectionOptions?: ConnectorOptions)Initialize database given a dialect and options.
Current Usage: const db = new Database(new SQLite3Connector({ filepath: "./db.sqlite" }));
const db = new Database({
connector: new SQLite3Connector({ ... }),
debug: true
});
Dialect usage: const db = new Database("sqlite3", { filepath: "./db.sqlite" });
const db = new Database({
dialect: "sqlite3",
debug: true
}, { ... });
Properties
private
_connector: Connectorprivate
_models: ModelSchema[]private
_queryBuilder: QueryBuilderprivate
_translator: TranslatorMethods
_computeModelFieldMatchings(): { toClient: FieldMatchingTable; toDatabase: FieldMatchingTable; }
Compute field matchings tables for model usage.
link(models: ModelSchema[])
Associate all the required information for a model to connect to a database.
await db.link([Flight, Airport]);
query(query: QueryDescription): Promise<Model | Model[]>
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 });
Static Methods
private
_convertDialectFormToConnectorForm(dialectOptionsOrDatabaseOptions: DialectDatabaseOptions,
connectionOptions: ConnectorOptions,
fromConstructor?,
private
_isInDialectForm(dialectOptionsOrDatabaseOptions: DatabaseOptions): booleanforDialect(dialectOptionsOrDatabaseOptions: Omit<DialectDatabaseOptions, "disableDialectUsageDeprecationWarning">, connectionOptions: ConnectorOptions): Database