database.js 883 B

123456789101112131415161718192021222324252627282930313233343536
  1. import { project } from "./project.js";
  2. import { element } from "./element.js";
  3. import { elements_list } from "./elements_list.js";
  4. import { submission } from "./submission.js";
  5. import { parser } from "./parser.js";
  6. class database {
  7. #project;
  8. constructor(content) {
  9. if (!(content instanceof Object)) {
  10. throw "Content to into database from must be an object.";
  11. }
  12. this.#load(content);
  13. }
  14. #load(content) {
  15. const loader = new parser(content, "root");
  16. this.#project = this.#parse_project(loader.get_parser("project"));
  17. }
  18. #parse_project(content) {
  19. const name = content.get("name");
  20. let description = "";
  21. if (content.exists("description")) {
  22. description = content.get("description");
  23. }
  24. return new project(name, description);
  25. }
  26. }
  27. export { database };