Skip to content

Commit

Permalink
chore: delete also time series data when perform delete on rooms and …
Browse files Browse the repository at this point in the history
…medical technologies
  • Loading branch information
AndreaGiulianelli committed Mar 12, 2023
1 parent f8998c5 commit ceb4d50
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions src/main/kotlin/infrastructure/database/DatabaseManager.kt
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,9 @@ class DatabaseManager(customConnectionString: String? = null) : RoomDatabaseMana
}

override fun deleteRoom(roomId: RoomID): Boolean = this.roomCollection.safeMongoDbWrite(defaultResult = false) {
roomTimeSeriesCollection.deleteMany(
TimeSeriesRoomEnvironmentalData::metadata / TimeSeriesRoomMetadata::roomId eq roomId
)
deleteOne(Room::id eq roomId).deletedCount > 0
}

Expand Down Expand Up @@ -121,6 +124,10 @@ class DatabaseManager(customConnectionString: String? = null) : RoomDatabaseMana

override fun deleteMedicalTechnology(medicalTechnologyId: MedicalTechnologyID): Boolean =
this.medicalTechnologiesCollection.safeMongoDbWrite(defaultResult = false) {
medicalTechnologyDataCollection.deleteMany(
TimeSeriesMedicalTechnologyUsage::metadata /
TimeSeriesMedicalTechnologyMetadata::medicalTechnologyId eq medicalTechnologyId
)
deleteOne(MedicalTechnology::id eq medicalTechnologyId).deletedCount > 0
}

Expand Down

0 comments on commit ceb4d50

Please sign in to comment.