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,12 +43,15 @@ class Data {
model: T model: T
): Promise<boolean> { ): Promise<boolean> {
try { try {
if (model._id) { if (!model._id) {
const oldModel = await this.get(model._id) const result = await this.locale?.put(model)
if (oldModel) { return result?.ok ?? false
const result = await this.locale?.put({ ...oldModel, ...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) const result = await this.locale?.put(model)