mirror of
https://github.com/smyalygames/checklist-tester.git
synced 2025-05-18 06:24:12 +02:00
feat(connector): add getProjectById
This commit is contained in:
parent
197bfc5966
commit
8e4ae16d7a
@ -29,6 +29,26 @@ internal class ProjectDatabase (driverFactory: DriverFactory) {
|
||||
)
|
||||
}
|
||||
|
||||
/**
|
||||
* Converts database [Project](io.anthonyberg.connector.shared.database.Project) data class to entity [Project] class
|
||||
*/
|
||||
private fun io.anthonyberg.connector.shared.database.Project.toProject() = Project(
|
||||
id = id.toInt(),
|
||||
name = name,
|
||||
aircraftType = aircraftType,
|
||||
createdUTC = createdUTC,
|
||||
modifiedUTC = modifiedUTC,
|
||||
)
|
||||
|
||||
/**
|
||||
* Gets Project from the unique ID of the Project
|
||||
* @param id Project id
|
||||
* @return [Project]
|
||||
*/
|
||||
private fun getProjectById(id: Int): Project {
|
||||
return dbQuery.selectProjectById(id.toLong()).executeAsOne().toProject()
|
||||
}
|
||||
|
||||
/**
|
||||
* Inserts a project into the database
|
||||
*/
|
||||
|
@ -13,5 +13,9 @@ VALUES (?, ?, ?);
|
||||
selectAllProjects:
|
||||
SELECT * FROM Project;
|
||||
|
||||
selectProjectById:
|
||||
SELECT * FROM Project
|
||||
WHERE id = ?;
|
||||
|
||||
countProjects:
|
||||
SELECT COUNT(*) FROM Project;
|
||||
|
Loading…
x
Reference in New Issue
Block a user