{"size": 600, "ext": "js", "max_stars_repo_path": "src/adapters/FsAdapter/methods/createCollection.js", "max_stars_repo_name": "vedmalex/TyrDB", "max_stars_repo_stars_event_min_datetime": "2019-09-17T15:03:03.000Z", "max_stars_repo_stars_event_max_datetime": "2021-11-18T04:19:40.000Z", "max_issues_repo_path": "src/adapters/FsAdapter/methods/createCollection.js", "max_issues_repo_name": "vedmalex/TyrDB", "max_issues_repo_issues_event_min_datetime": "2020-08-29T04:28:57.000Z", "max_issues_repo_issues_event_max_datetime": "2020-12-30T22:57:49.000Z", "max_forks_repo_path": "src/adapters/FsAdapter/methods/createCollection.js", "max_forks_repo_name": "vedmalex/TyrDB", "max_forks_repo_forks_event_min_datetime": "2020-04-01T05:58:54.000Z", "max_forks_repo_forks_event_max_datetime": "2020-12-30T17:15:47.000Z"}
{"max_stars_count": 26, "max_issues_count": 5, "max_forks_count": 3, "avg_line_length": 40.0, "max_line_length": 86, "alphanum_fraction": 0.6883333333}
const Collection = require('../../../types/Collection/Collection');

module.exports = async function createCollection(tyrInstance, dbName, colName, opts) {
  const collection = new Collection({
    name: colName, adapter: this, tyrInstance, parentDatabaseName: dbName, ...opts,
  });
  const path = `${tyrInstance.options.path}/${dbName}/${colName}/meta.json`;
  // FIXME : Do we actually really want to wait ?
  await this.queue.add('File.create', path, collection.export()).execution();

  return new Promise((resolve) => {
    collection.emitter.once('ready', () => resolve(collection));
  });
};
