Changing database schema a bit

This commit is contained in:
Gregory Ballantine 2024-06-08 09:47:48 -04:00
parent 584a6087ba
commit 7375c1ce39
6 changed files with 13 additions and 9 deletions

View File

@ -26,4 +26,8 @@ Benchmark.hasMany(Result);
Result.belongsTo(Test); Result.belongsTo(Test);
Test.hasMany(Result); Test.hasMany(Result);
// Result/Hardware many-to-one
Result.belongsTo(Hardware);
Hardware.hasMany(Result);
module.exports = sequelize; module.exports = sequelize;

View File

@ -2,7 +2,7 @@ const { Sequelize } = require("sequelize");
module.exports = (sequelize) => { module.exports = (sequelize) => {
const Test = sequelize.define('Test', { const Test = sequelize.define('Test', {
dateTag: { title: {
type: Sequelize.STRING, type: Sequelize.STRING,
null: false, null: false,
}, },

View File

@ -41,7 +41,7 @@ exports.getAdd = async function(req, res) {
// POST /test/add - add the test to the database // POST /test/add - add the test to the database
exports.postAdd = async function(req, res) { exports.postAdd = async function(req, res) {
var test = await Test.create({ var test = await Test.create({
dateTag: req.body.test_date_tag, title: req.body.test_title,
description: req.body.test_description, description: req.body.test_description,
}); });

View File

@ -9,9 +9,9 @@
<form class="twelve columns" action="/test/add" method="POST"> <form class="twelve columns" action="/test/add" method="POST">
<div class="row"> <div class="row">
<div class="three columns"> <div class="three columns">
<label for="test_date_tag"> <label for="test_title">
Test date tag: Test title:
<input id="test_date_tag" class="u-full-width" type="text" name="test_date_tag" placeholder="(XX/YY)"> <input id="test_title" class="u-full-width" type="text" name="test_title" placeholder="My test">
</label> </label>
</div> </div>

View File

@ -10,7 +10,7 @@
<table class="twelve columns"> <table class="twelve columns">
<thead> <thead>
<tr> <tr>
<td>Date Tag</td> <td>Title</td>
<td>Created at</td> <td>Created at</td>
<td>Last updated</td> <td>Last updated</td>
</tr> </tr>
@ -18,7 +18,7 @@
<tbody> <tbody>
{% for t in tests %} {% for t in tests %}
<tr> <tr>
<td><a href="/test/{{ t.id }}">{{ t.dateTag }} {{ t.getHardware().name }}</a></td> <td><a href="/test/{{ t.id }}">{{ t.title }}</a></td>
<td>{{ t.createdAt | date('m/d/Y g:ia') }}</td> <td>{{ t.createdAt | date('m/d/Y g:ia') }}</td>
<td>{{ t.updatedAt | date('m/d/Y g:ia') }}</td> <td>{{ t.updatedAt | date('m/d/Y g:ia') }}</td>
</tr> </tr>

View File

@ -1,10 +1,10 @@
{% extends 'layouts/default.twig' %} {% extends 'layouts/default.twig' %}
{% block title %}Test: {{ test.getHardware().name }} - {{ test.dateTag }}{% endblock %} {% block title %}Test: {{ test.title }}{% endblock %}
{% block content %} {% block content %}
<div class="row"> <div class="row">
<h2>Test: {{ test.getHardware().name }} - {{ test.dateTag }}</h2> <h2>Test: {{ test.title }}</h2>
</div> </div>
<hr> <hr>