Skip to main content
Module

x/mongo/src/database.ts>Database

MongoDB driver for Deno
Extremely Popular
Latest
class Database
import { Database } from "https://deno.land/x/mongo@v0.33.0/src/database.ts";

A Database on a MongoDB Server

Constructors

new
Database(cluster: Cluster, name: string)

Methods

collection<T extends Document = Document>(name: string): Collection<T>

Get a collection by name

createCollection<T extends Document>(name: string, options?: CreateCollectionOptions): Promise<Collection<T>>

createCollection executes a create command to create a new collection with the specified name and options.

https://www.mongodb.com/docs/manual/reference/command/create/#mongodb-dbcommand-dbcmd.create

createUser(
username: string,
password: string,
): Promise<Document>

Create a user on the Database

dropDatabase(writeConcern?: WriteConcern): Promise<Document>

Drop a database, optionally providing a writeConcern

dropUser(username: string, options?: { writeConcern?: Document; comment?: Document; }): Promise<Document>
listCollectionNames(options?: { filter?: Document; authorizedCollections?: boolean; comment?: Document; }): Promise<string[]>

List all collection names in the database

listCollections(options?: { filter?: Document; nameOnly?: boolean; authorizedCollections?: boolean; comment?: Document; }): CommandCursor<ListCollectionsResult>

List all collections in the database

runCommand<T = any>(body: Document): Promise<T>

Run a command on the Database