mirror of
https://github.com/smyalygames/checklist-tester.git
synced 2025-05-18 06:24:12 +02:00
feat(connector): add count projects function
This commit is contained in:
parent
ac986abcb3
commit
0013cf1a41
@ -10,6 +10,13 @@ import io.anthonyberg.connector.shared.entity.Project
|
||||
class ProjectTransaction (driverFactory: DriverFactory) {
|
||||
private val database = ProjectDatabase(driverFactory)
|
||||
|
||||
/**
|
||||
* Creates a project in the database.
|
||||
*/
|
||||
fun createProject(project: Project) {
|
||||
database.createProject(project)
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets all Projects in the database.
|
||||
*/
|
||||
@ -19,9 +26,17 @@ class ProjectTransaction (driverFactory: DriverFactory) {
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a project in the database.
|
||||
* Gets the number of projects in the database
|
||||
*/
|
||||
fun createProject(project: Project) {
|
||||
database.createProject(project)
|
||||
fun countProjects(): Long {
|
||||
return database.countProjects()
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if projects are on the database.
|
||||
* @return `true` if projects exist
|
||||
*/
|
||||
fun projectExists(): Boolean {
|
||||
return database.countProjects() > 0
|
||||
}
|
||||
}
|
||||
|
@ -39,4 +39,11 @@ internal class ProjectDatabase (driverFactory: DriverFactory) {
|
||||
createdUTC = project.createdUTC,
|
||||
)
|
||||
}
|
||||
|
||||
/**
|
||||
* Counts the amount of entries there are for projects
|
||||
*/
|
||||
internal fun countProjects(): Long {
|
||||
return dbQuery.countProjects().executeAsOne()
|
||||
}
|
||||
}
|
||||
|
@ -12,3 +12,6 @@ VALUES (?, ?, ?);
|
||||
|
||||
selectAllProjects:
|
||||
SELECT * FROM Project;
|
||||
|
||||
countProjects:
|
||||
SELECT COUNT(*) FROM Project;
|
||||
|
Loading…
x
Reference in New Issue
Block a user