INNER CODE UNIT · TypeScript

Database

denodrivers/mongo · src/database.ts:31

export class Database {
  #cluster: Cluster;

  constructor(cluster: Cluster, readonly name: string) {
    this.#cluster = cluster;
  }

  /** Drop a database, optionally providing a writeConcern */
  async dropDatabase(writeConcern?: WriteConcern): Promise<Document> {
    return await this.#cluster.protocol.commandSingle(this.name, {
      dropDatabase: 1,
      writeConcern,
    });
  }

  /** Get a collection by name */
  collection<T extends Document = Document>(name: string): Collection<T> {
    return new Collection<T>(this.#cluster.protocol, this.name, name);

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…