Use "transaction" to speed up group of queries
as this project is a template, this will help people understand how to run batch of queries.
This commit is contained in:
parent
fee35c235d
commit
328bf185ba
1 changed files with 6 additions and 3 deletions
|
@ -47,9 +47,12 @@ class PeopleInSpaceRepository : KoinComponent {
|
|||
|
||||
// this is very basic implementation for now that removes all existing rows
|
||||
// in db and then inserts results from api request
|
||||
peopleInSpaceQueries?.deleteAll()
|
||||
result.people.forEach {
|
||||
peopleInSpaceQueries?.insertItem(it.name, it.craft)
|
||||
// using "transaction" accelerate the batch of queries, especially inserting
|
||||
peopleInSpaceQueries?.transaction {
|
||||
peopleInSpaceQueries?.deleteAll()
|
||||
result.people.forEach {
|
||||
peopleInSpaceQueries?.insertItem(it.name, it.craft)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue