-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathhelperRepository.js
More file actions
29 lines (22 loc) · 1.08 KB
/
helperRepository.js
File metadata and controls
29 lines (22 loc) · 1.08 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
const config = require('../../config.js');
const getDBClient = require('./dbClient');
const dbClient = getDBClient(config.getConnections().mysql);
var helperRepository = {
createContentObject: async function (contentObjectType, transaction) {
const query =
`INSERT INTO ContentObject (ContentObjectTypeId) VALUES (:contentObjectType);
SELECT last_insert_id() AS Id;`;
var connection = await dbClient.getConnectionAsync(transaction);
var result = await connection.queryAsync(query, {contentObjectType});
return result[1][0].Id;
},
getUserInfo: async function (studentId, transaction) {
const query =
`SELECT StudentTypeId, StudentDegreeLevelId, UniversityId, SchoolId, AreaId, CourseId
FROM dbo.Student WHERE Id = :studentId`;
var connection = await dbClient.getConnectionAsync(transaction);
var result = await connection.queryAsync(query, {studentId});
return result[0];
}
};
module.exports = helperRepository;