mirror of
https://github.com/sergeyyarkov/educt-server.git
synced 2026-10-11 10:19:20 +03:00
fix: fixed category updating
This commit is contained in:
parent
bac861a09d
commit
6248134614
@ -14,7 +14,7 @@ export default class Category extends BaseModel {
|
||||
public title: string;
|
||||
|
||||
@column()
|
||||
public description: string;
|
||||
public description: string | null;
|
||||
|
||||
@column({ serializeAs: null })
|
||||
public color_id: number | null;
|
||||
|
||||
@ -70,6 +70,7 @@ export default class CategoryRepository {
|
||||
}
|
||||
|
||||
/**
|
||||
* Update category by id
|
||||
*
|
||||
* @param id Category id
|
||||
* @param data
|
||||
@ -79,13 +80,7 @@ export default class CategoryRepository {
|
||||
const category = await this.Category.query().where('id', id).first();
|
||||
|
||||
if (category) {
|
||||
await category
|
||||
.merge({
|
||||
title: data.title,
|
||||
description: data.description,
|
||||
})
|
||||
.save();
|
||||
|
||||
await category.merge(data).save();
|
||||
return category;
|
||||
}
|
||||
|
||||
|
||||
@ -144,7 +144,7 @@ export default class CategoryService {
|
||||
success: true,
|
||||
status: HttpStatusEnum.OK,
|
||||
message: 'Category updated.',
|
||||
data,
|
||||
data: category,
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
@ -6,7 +6,7 @@ export default class UpdateCategoryValidator {
|
||||
|
||||
public schema = schema.create({
|
||||
title: schema.string.optional(),
|
||||
description: schema.string.optional(),
|
||||
description: schema.string.nullableAndOptional(),
|
||||
});
|
||||
|
||||
public messages = {};
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user