[platform] Use upsert instead of handmade check for entity existence

GitOrigin-RevId: 0f8da0b94d763d699c6768e755f6847599e5e615
This commit is contained in:
Nikolay Rykunov
2024-09-17 17:57:07 +02:00
committed by intellij-monorepo-bot
parent e30be0c48b
commit 355cbae734

View File

@@ -47,14 +47,8 @@ abstract class ProjectEntitiesStorage {
If it happens that the entity has not been found and the frontend creates a new one, Rhizome DB will perform a "rebase"
which basically re-invokes the whole "change" block either on the backend or the frontend side.
*/
val existing = entity<ProjectEntity, ProjectId>(ProjectEntity.ProjectIdValue, projectId)
if (existing != null) {
existing
}
else {
ProjectEntity.new {
it[ProjectEntity.ProjectIdValue] = projectId
}
ProjectEntity.upsert(ProjectEntity.ProjectIdValue, projectId) {
it[ProjectEntity.ProjectIdValue] = projectId
}
}
}