1
0
mirror of https://github.com/matt-fidd/stratos.git synced 2026-01-01 20:59:30 +00:00

Add TestTemplate.createTestTemplate

This commit is contained in:
2022-03-08 13:05:40 +00:00
parent 57def008c8
commit ca5f7cc6e2

View File

@@ -1,6 +1,8 @@
/* eslint-disable no-empty-function, getter-return */
'use strict';
const crypto = require('crypto');
// Import user defined modules
const DatabaseConnectionPool = require('./DatabaseConnectionPool');
@@ -86,8 +88,31 @@ class TestTemplate {
}
static createTestTemplate() {
static async createTestTemplate(accountId, name, maxMark) {
const a = await new (require('./Account'))(accountId);
const id = crypto.randomUUID();
const conn = await new DatabaseConnectionPool();
const sql = `
insert into testTemplate(
testTemplateId,
accountId,
name,
maxMark)
values
(?, ?, ?, ?);
`;
await conn.runQuery(sql, [
id,
a.id,
name,
maxMark
]);
return new TestTemplate(id);
}
}