refacto: less if in if

This commit is contained in:
Julien Calixte
2024-10-27 11:34:40 +01:00
parent 0d218fa25d
commit 42778ef889

View File

@@ -43,13 +43,16 @@ class Data {
model: T
): Promise<boolean> {
try {
if (model._id) {
if (!model._id) {
const result = await this.locale?.put(model)
return result?.ok ?? false
}
const oldModel = await this.get(model._id)
if (oldModel) {
const result = await this.locale?.put({ ...oldModel, ...model })
return result?.ok ?? false
}
}
const result = await this.locale?.put(model)
return result?.ok ?? false