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
}, { ... });
Methods
_computeModelFieldMatchings(): { toClient: FieldMatchingTable; toDatabase: FieldMatchingTable; }
table: string,
fields: ModelFields,
withTimestamps: boolean,
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<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 });