{"size": 777, "ext": "js", "max_stars_repo_path": "api/src/models/quests.model.js", "max_stars_repo_name": "temekuweb/tqks-featherweight-prototype", "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "api/src/models/quests.model.js", "max_issues_repo_name": "temekuweb/tqks-featherweight-prototype", "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "api/src/models/quests.model.js", "max_forks_repo_name": "temekuweb/tqks-featherweight-prototype", "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null}
{"max_stars_count": null, "max_issues_count": null, "max_forks_count": null, "avg_line_length": 22.8529411765, "max_line_length": 54, "alphanum_fraction": 0.6293436293}
/**
 * A Quest is an object with these fields
 *  id -- UUID
 *  creatorId -- String
 *  createdDaate -- Date
 *  label -- String
 *  details -- String -- rich text
 *  questionList -- Array of String
 *  answerList -- Array of String
 *  proList -- Array of String
 *  conList -- Array of String
 *  tagList -- Array of String  (later)
 *  connectionList -- Array of String  (later)
 * 
 * We are indexing by
 *  id
 *  label
 */

const NeDB = require('nedb');
const path = require('path');

module.exports = function (app) {
  const dbPath = app.get('nedb');
  const Model = new NeDB({
    filename: path.join(dbPath, 'quests.db'),
    autoload: true
  });
  Model.ensureIndex({ fieldName: 'id', unique: true })
  Model.ensureIndex({ fieldName: 'label'})

  return Model;
};
