refacto: less if in if
This commit is contained in:
@@ -43,13 +43,16 @@ class Data {
|
|||||||
model: T
|
model: T
|
||||||
): Promise<boolean> {
|
): Promise<boolean> {
|
||||||
try {
|
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)
|
const oldModel = await this.get(model._id)
|
||||||
if (oldModel) {
|
if (oldModel) {
|
||||||
const result = await this.locale?.put({ ...oldModel, ...model })
|
const result = await this.locale?.put({ ...oldModel, ...model })
|
||||||
return result?.ok ?? false
|
return result?.ok ?? false
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
const result = await this.locale?.put(model)
|
const result = await this.locale?.put(model)
|
||||||
return result?.ok ?? false
|
return result?.ok ?? false
|
||||||
|
|||||||
Reference in New Issue
Block a user