<commit_before>const Collection = require('./collection');
const { MongoClient } = require('mongodb');

class Database {
  static async connect(uri, options) {
    const db = new Database();
    db.db = await MongoClient.connect(uri, options);
    db.collections = {};
    return db;
  }

  collection(name, archetype) {
    this.collections[name] = new Collection(this.db.collection(name), archetype);
    return this.collections[name];
  }

  async dropDatabase() {
    return this.db.dropDatabase();
  }
}

module.exports = Database;<commit_msg>add collections getter<commit_after>const Collection = require('./collection');
const { MongoClient } = require('mongodb');

class Database {
  static async connect(uri, options) {
    const db = new Database();
    db.db = await MongoClient.connect(uri, options);
    db.collections = {};
    return db;
  }

  collection(name, archetype) {
    if (this.collections[name]) {
      return this.collections[name];
    }
    this.collections[name] = new Collection(this.db.collection(name), archetype);
    return this.collections[name];
  }

  async dropDatabase() {
    return this.db.dropDatabase();
  }
}

module.exports = Database;
{'fraction_non_alphanumeric': 0.13790186125211507, 'fraction_numerical': 0.0, 'mean_word_length': 3.8285714285714287, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6489532', 'n_tokens_mistral': 363, 'n_tokens_neox': 347, 'n_words': 79}