mirror of
https://github.com/matt-fidd/stratos.git
synced 2026-01-01 22:19:26 +00:00
Added Account.getTestTemplates method
This commit is contained in:
@@ -1,6 +1,9 @@
|
||||
/* eslint-disable no-empty-function, getter-return */
|
||||
'use strict';
|
||||
|
||||
const DatabaseConnectionPool = require('./DatabaseConnectionPool');
|
||||
|
||||
const TestTemplate = require('./TestTemplate');
|
||||
const User = require('./User');
|
||||
|
||||
class Account extends User {
|
||||
@@ -8,12 +11,26 @@ class Account extends User {
|
||||
super('account', id);
|
||||
}
|
||||
|
||||
get classes() {
|
||||
async getTestTemplates() {
|
||||
const sql = `
|
||||
select
|
||||
testTemplateId as id
|
||||
from
|
||||
testTemplate
|
||||
where
|
||||
accountId = ?;
|
||||
`;
|
||||
|
||||
}
|
||||
const conn = await new DatabaseConnectionPool();
|
||||
const records = await conn.runQuery(sql, [ this.id ]);
|
||||
|
||||
get testTemplates() {
|
||||
const promises = records.map(record => {
|
||||
return new TestTemplate(record.id);
|
||||
});
|
||||
|
||||
const objects = await Promise.all(promises);
|
||||
|
||||
return objects;
|
||||
}
|
||||
|
||||
createTestTemplate() {
|
||||
|
||||
Reference in New Issue
Block a user